struts 2 action with no setter getter

99封情书 提交于 2019-12-01 00:07:26

You can exclude some properties from the accepted parameters for params interceptor by setting parameter excludeParams to the interceptor. By default this parameter is initialized with

<interceptor-ref name="params">
  <param name="excludeParams">dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,parameters\...*</param>
</interceptor-ref>

You should add you properties here, it accepts the regex pattern to match the property names. The strategy applied with accepted parameter names could be compromised via the ParameterNameAware implemented actions where you could remove the restriction given above.

To be more specific about "data coming from the user interface" I'd adhere that parameters to the interceptor-ref element is applied to the interceptor on start up and is not stored elsewhere in the configuration manager. This means you can't get this parameters at runtime and only could change via updating and reloading the configuration file struts.xml. If you keep your configuration in the safe place and it's protected from modification then you could make more claims toward your running application safety.

jonathan.cone

Yes, you need to remove the Struts params interceptor mapping for this specific action. I believe you can take an approach similar to the one in this related question. Otherwise you will have to create another interceptor stack with the interceptors you desire, minus the parameter interceptor and map the action to that stack in struts.xml or use the @InterceptorRef annotation on your action class, assuming you're using the convention plugin.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!