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>

  • 相关阅读:
    app已损坏,打不开。你应该将它移到废纸篓。
    Mac/win eclipse genymotion 插件下载地址
    过大年
    error: L6235E: More than one section matches selector
    android socket 线程连接openwrt与arduino单片机串口双向通信
    PCB对应封装元件名称
    网页代码总结
    sql一个表中的数据插入到另外一个表中
    树莓派更换镜像源
    SQL 中的 AND OR
  • 原文地址:https://www.cnblogs.com/flying607/p/3473321.html
Copyright © 2011-2022 走看看