zoukankan      html  css  js  c++  java
  • struts 防止重复提交表单

    <?xml version="1.0" encoding="UTF-8" ?>

    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
        "http://struts.apache.org/dtds/struts-2.1.dtd">

    <struts>


        <constant name="struts.devMode" value="true"></constant>
        <package name="test" namespace="/" extends="struts-default">
           
        <action name="input" class="com.bjsxt.action.InputAction">
                <result>/input.jsp</result>
               
               
            </action>

            <action name="user" class="com.bjsxt.action.UserAction">
                <result>/addOK.jsp</result>
               
               
                <interceptor-ref name="defaultStack"></interceptor-ref>
                <interceptor-ref name="token"></interceptor-ref><!--  该重复提交拦截器一定要在defaultStack拦截器外边 -->
                <result name="invalid.token">/error.jsp</result><!--  重复提交会跳转到该页面 -->
            </action>

        </package>


    </struts>

     

     

    防止重复提交要在表单里面添加标签:

     

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <%@taglib uri="/struts-tags" prefix="s" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
       
        <title>My JSP 'test.jsp' starting page</title>
       
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">   
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->

      </head>
     
      <body>
        <form action="user" method="post">
            name:<input name="name">
            age:<input name="age">
            <input type="submit" value="add">
            <s:token></s:token>
        </form><br>
      </body>
    </html>

  • 相关阅读:
    c#自动更新+安装程序的制作
    VS2013项目受源代码管理向源代码管理注册此项目时出错
    WinDbg配置和使用基础
    InstallShield Limited Edition for Visual Studio 2013 图文教程(教你如何打包.NET程序)
    PowerDesigner 如何生成数据库更新脚本
    用户故事(User Story)
    Troubleshooting Record and Playback issues in Coded UI Test
    Coded UI
    compare two oracle database schemas
    How to: Use Schema Compare to Compare Different Database Definitions
  • 原文地址:https://www.cnblogs.com/flying607/p/3473321.html
Copyright © 2011-2022 走看看