THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.ParentPackage; @ParentPackage("customXWorkPackage") public class HelloWorld extends ActionSupport { public String execute() { return SUCCESS; } } |
ExceptionMapping
This annotation can be used to define exception mappings to actions. See the exception mapping documentation for more details. These mappings can be applied to the class level, in which case they will be applied to all actions defined on that class:
Code Block | ||
---|---|---|
| ||
@ExceptionMappings({
@ExceptionMapping(exception = "java.lang.NullPointerException", result = "success", params = {"param1", "val1"})
})
public class ExceptionsActionLevelAction {
public String execute() throws Exception {
return null;
}
}
|
The parameters defined by params are passed to the result. Exception mappings can also be applied to the action level:
Code Block |
---|
public class ExceptionsMethodLevelAction {
@Action(value = "exception1", exceptionMappings = {
@ExceptionMapping(exception = "java.lang.NullPointerException", result = "success", params = {"param1", "val1"})
})
public String run1() throws Exception {
return null;
}
}
|
Configuration reference
Add a constant element to your struts config file to change the value of a configuration setting, like:
...