The name
is the property of the model and also the property of the action class. The modelDriven
interceptor pushes the model on top of the value stack, so it is easy to use it in JSP. The action object is below the model. So, it could be referenced directly using [1]
prefix. See OGNL basics.
But it’s not necessary if there’s no duplicate property names in the model and action object. When the name such as name
is evaluated by OGNL it searches from the top of the valueStack
to down the stack for the property accessor. The first found accessor will be executed. So, the model property has a priority because the model is on top of the value stack.
If the property with the name name
should be set on the action then you could directly name that property as [1].name
. But, such parameter name is not accepted by default pattern of params
interceptor. However, it is a valid OGNL expression. So, to get it pass through the interceptor you need to add it to a pattern of accepted parameter names. Like that
@Action(value="modelDrivenResult", results=@Result(location = "/modelDriven/modelDrivenResult.jsp"),
interceptorRefs = @InterceptorRef(value="defaultStack", params={
"params.acceptParamNames", "(\\[\\d+\\]\\.)*\\w+((\\.\\w+)|(\\[\\d+\\])|(\\(\\d+\\))|(\\['\\w+'\\])|(\\('\\w+'\\)))*"
})
)
This is because OGNL also checks the pattern of accepted parameters and this regex pattern allows to match both params
and OGNL matchers.