In Struts2 it's very convenient to use domain driven in a action,however,The problem comes when the data gets automatically transferred onto the object. As we’ve seen, if the request has parameters that match the attributes on your domain object, the data will be moved onto those attributes. Now, consider the case where your domain object has some sensitive data attributes that you don’t really want to expose to this automatic data transfer, perhaps an ID,how can we exclude them? In asp.net mvc we can use exclude annotation to do it easily: Bind(Exclude="empId")]
, do we have similar approach to do this?
问问题
180 次
1 回答
0
您可以使用params
拦截器执行此操作。拦截器是其中的一部分,defaultStack
您可以在外包装中对其进行配置,也可以将其单独应用于操作。它具有属性excludeParams
,您可以使用此参数来配置需要从总体中排除的属性。与您一起或在您的支持下ParameterNameAware
,可以将用于定义接受参数列表和黑名单的逻辑分开。ParameterNameAware
关于它能够揭示拦截器排除的参数的 一个注意事项。
于 2013-07-07T18:19:57.940 回答