struts.xml配置文件

   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

   "http://struts.apache.org/dtds/struts-2.0.dtd">


     

   


   

   

   

       

           

           

           

           /WEB-INF/page/error.jsp

           /WEB-INF/page/message.jsp

       

       

           

           

           

           /WEB-INF/page/error.jsp

           /WEB-INF/page/message.jsp

       

   

publicclass PersonAction {

private String name;

   @SuppressWarnings(
"unchecked")
//观看控制台
//如果token生效则不会在控制台输出name的值,而会输出如下警告: 2011-3-14 20:45:32 com.opensymphony.xwork2.util.logging.commons.CommonsLogger
//warn 警告: Form token EDZ4S96RNDN5VD8B1CQTK6FTHIJUPC66 does not match the session token null.
public String execute() {
       List ls
=new ArrayList();
       ls.add(name);
for (int i =0; i < ls.size(); i++) {
           System.out.println(ls.get(i));
       }
return"success";
   }

public String getName() {
return name;
   }

publicvoid setName(String name) {
this.name = name;
   }
}

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib uri="/struts-tags" prefix="s"%>

 


   防止表单重复提交

   

   

     

 


 

     

     

     

         姓名:

         

     

 

<%@ page language="java"import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>My JSP 'index.jsp' starting pagetitle>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
head>

<body>
<s:property value="name"/><br/>
<%=new Date() %>
body>
html>

<%@ page language="java"import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
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 'error.jsp' starting pagetitle>

<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">


head>

<body>
     您已经提交了表单,请不要重复提交。
body>
html>