How to specify multiple acceptParamNames in Struts2 using annotations (convention plugin)?

619 views Asked by At

I'm trying to set multiple acceptable parameters through the params interceptor like as follows.

@Namespace("/admin_side")
@ResultPath("/WEB-INF/content")
@InterceptorRefs({
    @InterceptorRef(value="defaultStack", 
        params={"params.excludeParams", "^action:(?!postAction$)\\w*$",
        "params.acceptParamNames", "action:postAction",
        "params.acceptParamNames", "id",
        "params.acceptParamNames", "name",
        "params.acceptParamNames", "email",
        "params.acceptParamNames", "number",
        "params.acceptParamNames", "deleteOneRow",        
        "validation.excludeMethods", "test"}),            
})
public final class TestAction extends ActionSupport implements Serializable, ValidationAware, ModelDriven<Transporter>
{
    //...
}

In this case, only the last parameter which is deleteOneRow (Boolean) is accepted. The rest are not accepted. Instead, it issues warnings as follows.

Dec 26, 2013 4:00:04 AM com.opensymphony.xwork2.interceptor.ParametersInterceptor warn
WARNING: Parameter [action:postAction] didn't match acceptParams list of patterns!
Dec 26, 2013 4:00:04 AM com.opensymphony.xwork2.interceptor.ParametersInterceptor warn
WARNING: Parameter [id] didn't match acceptParams list of patterns!
Dec 26, 2013 4:00:04 AM com.opensymphony.xwork2.interceptor.ParametersInterceptor warn
WARNING: Parameter [email] didn't match acceptParams list of patterns!
Dec 26, 2013 4:00:04 AM com.opensymphony.xwork2.interceptor.ParametersInterceptor warn
WARNING: Parameter [name] didn't match acceptParams list of patterns!
Dec 26, 2013 4:00:04 AM com.opensymphony.xwork2.interceptor.ParametersInterceptor warn
WARNING: Parameter [number] didn't match acceptParams list of patterns!

How to set multiple parameters to params.acceptParamNames using convention plugin?

1

There are 1 answers

0
Tiny On BEST ANSWER

So, the answer is as simple as follows.

@InterceptorRefs({
    @InterceptorRef(value="defaultStack", 
    params={"params.excludeParams", "^action:(?!postAction$)\\w*$",
   "params.acceptParamNames", "^action:(?!postAction$)\\w*$, id, name, email, number, deleteOneRow", 
    "validation.excludeMethods", "test"})
})

Among from these parameters, ^action:(?!postAction$)\\w*$ is a parameter of submit button, <s:submit> that doesn't work issuing a warning, WARNING: Parameter [action:postAction] didn't match acceptParams list of patterns! but it could be a different question.