使用struts-2.3.28- 所需要基本的jar 包,如下图:
web.xml 中基本的配置如下:
基本struts.xml 如下;注意 struts.xml 文件应放在src 目录下
<?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>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="index" />
<global-results>
<result name="error">/WEB-INF/jsp/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
<action name="addVote" class="com.leon.loco.vote.action.AddVoteAction">
<result name="success">/admin/addVote.jsp</result>
</action>
<action name="deleteVote" class="com.leon.loco.vote.action.DeleteVoteAction">
<result name="success" type="chain">showVote</result>
</action>
</package>
</struts>
其中第一个action 结果会转到一个jsp 页面,第二个action 会转到另一个action 处理