我试图通过params
拦截器设置多个可接受的参数,如下所示。
@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>
{
//...
}
在这种情况下,只接受deleteOneRow
(Boolean
)的最后一个参数。其余的不被接受。相反,它发出如下警告。
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!
如何使用约定插件将多个参数设置为params.acceptParamNames
?
答案 0 :(得分:0)
所以,答案很简单如下。
@InterceptorRefs({
@InterceptorRef(value="defaultStack",
params={"params.excludeParams", "^action:(?!postAction$)\\w*$",
"params.acceptParamNames", "^action:(?!postAction$)\\w*$, id, name, email, number, deleteOneRow",
"validation.excludeMethods", "test"})
})
在这些参数中, ^action:(?!postAction$)\\w*$
是提交按钮的参数,<s:submit>
无法发出警告WARNING: Parameter [action:postAction] didn't match acceptParams list of patterns!
,但可能是另一个问题。