zoukankan      html  css  js  c++  java
  • [原]struts2 令牌 实现源代码 JSP

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib prefix="s" uri="/struts-tags"%>  <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  <html>   <head>     <base href="<%=basePath%>">          <title>My JSP 'Struts_token.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表单里填上<s:token></s:token>      -->       <!-- action="token"、action="tokenSession" -->       <s:form action="token.action" namespace="/test" method="post">           姓名:<s:textfield name="name"/><s:token></s:token>           <input type="submit" value="发送"/>       </s:form>   </body> </html> 
     
    其实很简单实用,只要在表单中在form表单里填上<s:token></s:token>   就可以了,是不是很简单。原理就是它会自动生成一串二进制码。STRUTS会自动在提交的时候去做比对。


  • 相关阅读:
    六、TreeSet中的定制排序
    五、Set接口
    四、List接口
    Vocabulary Recitation 2020/05/20
    Vocabulary Recitation 2020/05/19
    Vocabulary Recitation 2020/05/18
    自控力_第六章
    Vocabulary Recitation 2020/05/17
    Vocabulary Recitation 2020/05/15
    Vocabulary Recitation 2020/05/14
  • 原文地址:https://www.cnblogs.com/java20131201/p/3475323.html
Copyright © 2011-2022 走看看