:
, , , , -, int, , Integer.parseInt , , ? numberformatexception , ?
Struts 2 , : , < > , , - , , , . INPUT, .
Parameters Interceptor . RuntimeException (, NumberFormatException) , devMode - true, Action Errors, . :
for (Map.Entry<String, Object> entry : acceptableParameters.entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
try {
newStack.setParameter(name, value);
} catch (RuntimeException e) {
if (devMode) {
String developerNotification = LocalizedTextUtil.findText(ParametersInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
"Unexpected Exception caught setting '" + name + "' on '" + action.getClass() + ": " + e.getMessage()
});
LOG.error(developerNotification);
if (action instanceof ValidationAware) {
((ValidationAware) action).addActionMessage(developerNotification);
}
}
}
}
Conversion Errors Interceptor , - : Field Error; , , . :
, ActionContextErrors ( , ValidationAware). , , , , , . , , "abc" int, ( "abc" ) , int (, 0, ).
Validation Interceptor ( XML, validate() validateXXX() ), Field Errors , .
Workflow Interceptor , Field Errors ( ). , . , INPUT.
, , ( ). struts-default.xml:
<interceptor-ref name="params">
<param name="excludeParams">^dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,^parameters\..*,^action:.*,^method:.*</param>
</interceptor-ref>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
:
, , ...? ?
: String int , Getter ; int, Integer, int , int: 0.
, Conversion Interceptor ( № 2), , Action ( null 0). :
.
, , . , , "abc" , . , , "" , , -, .
...
, .
, ... ?
(, , ) value:
0 abc:
<s:textfield name = "myIntField"
value = "%{getText('format.number',{myIntField})}" />
.
, , abc abc:
<s:textfield name = "myIntField" />
<s:textfield name = "myIntField"
value = "%{myIntField}" />
value, , , .