stucts2 表单重复提交拦截器 token

直接上代码:
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>
    <!-- 设置该应用使用的解码集 -->
    <constant name="struts.i18n.encoding" value="utf-8" />
    <constant name="struts.custom.i18n.resources" value="mess" />
    <constant name="struts.devMode" value="true" />

    <package name="default" extends="struts-default">
        <action name="test" class="com.bh.action.TookenAction">

            <!-- 重复提交跳转到错误界面 -->
            <!-- <result name="invalid.token">/error.jsp</result> <result>/Succ.jsp</result> <interceptor-ref name="defaultStack" /> <interceptor-ref name="token" /> -->
            <!-- 重复提交跳转到成功界面 -->
            <result>/Succ.jsp</result>

            <interceptor-ref name="tokenSession" />

        </action>
    </package>

</struts>

jsp界面:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

    <s:actionerror />
    <s:form action="test">
        <s:textfield name="message" label="Message" />
        <%-- 注意这里,token标签--%>
        <s:token />
        <s:submit />
    </s:form>
</body>
</html>

你可能感兴趣的:(struts,表单,token)