您的位置:首页 > 编程语言 > Java开发

struts2 学习

2016-04-17 21:57 197 查看
使用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 处理

注意到第二个action 中的result 标签,使用了
type="chain"
, 这应该是连续处理的一个关键词

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: