标签:
1、导入jar包

2、编写web.xml文件
<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>
3、写一个action
public class Demo1Action extends ActionSupport { public String test1(){ return SUCCESS; } }
4、编码struts.xml文件

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="test" namespace="/" extends="struts-default"> <action name="action_*" class="com.test.Demo1Action" method="{1}"> <result>success.jsp</result> <result name="error">error.jsp</result> </action> </package> </struts>
package
name:包名
namespace:命名空间
extends:继承
action
name:访问时路径名
class:类的全名
method:执行方法
result:结果集
type:结果集的类型
name:和方法返回值一样
标签:
原文地址:http://www.cnblogs.com/jsnan/p/4505862.html