struts2 学习

使用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", 这应该是连续处理的一个关键词

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值