首页 > 学院 > 开发设计 > 正文

Struts开发流程

2019-11-06 08:01:36
字体:
来源:转载
供稿:网友

Struts开发流程:

A:导入jar包

commons-fileupload-1.2.2.jarcommons-io-2.0.1.jarcommons-lang3-3.1.jarfreemarker-2.3.19.jarjavassist-3.11.0.GA.jarognl-3.0.5.jarstruts2-core-2.3.4.1.jarxwork-core-2.3.4.1.jar

 

B:配置web.xml

<!-- 引入struts核心过滤器 --><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPRepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping>

C:开发action类

// 开发action: 处理请求public class HelloAction extends ActionSupport {// 处理请求public String execute() throws Exception {System.out.println("访问到了action,正在处理请求");System.out.println("调用service");return "success";}}

D:配置struts.xml

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC          "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"          "http://struts.apache.org/dtds/struts-2.0.dtd"><struts>    <package name="xxxx" extends="struts-default">    	<action name="hello" class="cn.lfsenior.action.HelloAction" method="execute">    	<result name="success">/success.jsp</result>    	</action>    </package> </struts>

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表