Tokenpublic class Token extends UIBean
Stop double-submission of forms.
The token tag is used to help with the "double click" submission problem. It is needed if you are using the
TokenInterceptor or the TokenSessionInterceptor. The s:token tag merely places a hidden element that contains
the unique token.
Examples
<s:token />
|
Fields Summary |
---|
public static final String | TEMPLATE |
Methods Summary |
---|
private java.lang.String | buildToken(java.lang.String name)
Map context = stack.getContext();
Object myToken = context.get(name);
if (myToken == null) {
myToken = TokenHelper.setToken(name);
context.put(name, myToken);
}
return myToken.toString();
| protected void | evaluateExtraParams()First looks for the token in the PageContext using the supplied name (or {@link org.apache.struts2.util.TokenHelper#DEFAULT_TOKEN_NAME}
if no name is provided) so that the same token can be re-used for the scope of a request for the same name. If
the token is not in the PageContext, a new Token is created and set into the Session and the PageContext with
the name.
super.evaluateExtraParams();
String tokenName;
Map parameters = getParameters();
if (parameters.containsKey("name")) {
tokenName = (String) parameters.get("name");
} else {
if (name == null) {
tokenName = TokenHelper.DEFAULT_TOKEN_NAME;
} else {
tokenName = findString(name);
if (tokenName == null) {
tokenName = name;
}
}
addParameter("name", tokenName);
}
String token = buildToken(tokenName);
addParameter("token", token);
addParameter("tokenNameField", TokenHelper.TOKEN_NAME_FIELD);
| protected java.lang.String | getDefaultTemplate()
return TEMPLATE;
| public java.lang.String | getTokenNameField()This will be removed in a future version of Struts.
return TokenHelper.TOKEN_NAME_FIELD;
|
|