<s:hidden name="url" value="http://www.h3.com" />
<input type="hidden" name="url" value="http://www.h3.com" />
hiddenaction.java
package com.h3.common.action;
import com.opensymphony.xwork2.actionsupport;
public class hiddenaction extends actionsupport{
private string url;
public string geturl() {
return url;
}
public void seturl(string url) {
this.url = url;
}
public string execute() {
return success;
}
}
hidden.jsp
<%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> </head> <body> <h1>struts 2 - 隐藏值字段</h1> <s:form action="hellohidden" namespace="/"> <h2>this page has a hidden value (view source): <s:hidden name="url" value="http://www.h3.com" /></h2> <s:submit value="submit" name="submit" /> </s:form> </body> </html>
welcome.jsp
<%@ page contenttype="text/html;charset=utf-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> <html> <body> <h1>struts 2 - 隐藏值字段</h1> <h2> the hidden value : <s:property value="url"/> </h2> </body> </html>
<?xml version="1.0" encoding="utf-8" ?> <!doctype struts public "-//apache software foundation//dtd struts configuration 2.0//en" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devmode" value="true" /> <package name="" namespace="/" extends="struts-default"> <action name="hidden"> <result>/pages/hidden.jsp</result> </action> <action name="hellohidden" class="com.h3.common.action.hiddenaction"> <result name="success">/pages/welcome.jsp</result> </action> </package> </struts>
http://localhost:8080/struts2hidden/hidden.action


