1.先配置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>
2.在src目录下面创建并配置struts.xml 之前要在window--》preference--》XMLCatalog中添加
<struts>
<package name="test" extends="struts-default">
<action name="TestAction" class="com.test.TestAction">
<result name="welcome" >welcome.jsp</result>
</action>
</package>
</struts>
3.创建action类 action类中一定要有set get 方法 execute方法
public String execute(){
System.out.println(name);
wel = "Welcome "+name;
return "welcome";
}
4.在jsp中输出数据:
<%@ taglib prefix="c" uri="/struts-tags" %>
<c:property value="wel"/>
<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>
2.在src目录下面创建并配置struts.xml 之前要在window--》preference--》XMLCatalog中添加
<struts>
<package name="test" extends="struts-default">
<action name="TestAction" class="com.test.TestAction">
<result name="welcome" >welcome.jsp</result>
</action>
</package>
</struts>
3.创建action类 action类中一定要有set get 方法 execute方法
public String execute(){
System.out.println(name);
wel = "Welcome "+name;
return "welcome";
}
4.在jsp中输出数据:
<%@ taglib prefix="c" uri="/struts-tags" %>
<c:property value="wel"/>