使用Struts的Token机制防止重复提交的问题的简单测试!
参考各位老大的经验,测试代码如下:
input.jsp:
<%@ page contentType="text/html; charset=GBK" %>
<html:html>
<head><title>Test</title></head>
<body>
<html:form action="/testAction.do" method="post">
<br>
<html:text property="name"/>
<br>
<html:text property="pass"/>
<br>
<html:submit property="submit" value="Submit"/><br>
</html:form>
</body>
</html:html>
success.jsp:
<html><head><title>success</title></head>
<body bgcolor="#ffffff">
success!
</body>
</html>
TestForm:
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="testActionForm" type="test.TestForm"/>
</form-beans>
<action-mappings>
<action name="testActionForm" path="/testAction" type="test.TestAction" scope="request" input="/index.jsp" validate="false">
<forward name="success" path="/success.jsp"/>
</action>
</action-mappings>
<message-resources parameter="ApplicationResources"/>
</struts-config>
编写完上边的代码后:http://localhost:8080/test/testAction.do可以进行测试! 1 楼 wensky222 2007-04-20 如果使用velocity模板,而不使用struts的标签(velocity),在struts2下怎么解决重复提交问题呢? 2 楼 sunsy 2007-04-20 WEBWORK以前在页面上可以用标签来声明一个TOKEN,现在STRUTS要写在ACTION里吗? 3 楼 cozone_柯中 2007-04-20 sunsy 写道WEBWORK以前在页面上可以用标签来声明一个TOKEN,现在STRUTS要写在ACTION里吗?
因为要在action里面判断token是否合法