Changing ParameterAware to HttpParametersAware

 ̄綄美尐妖づ 提交于 2019-12-20 04:49:48

问题


I'm upgrading my project from struts 2.3.1 to 2.5.12 Since ParametersAware is deprecated in 2.5.12, I want to change ParametersAware to HttpParametersAware.

But setParameter() method is entirely different in both.

  1. setParameters(HttpParameters parameters) (struts 2.5.12)
  2. setParameters(Map<String,String[]> parameters) (struts 2.3.1)

How to do this?


回答1:


Change Map<String,String[]> to HttpParameters. The later class implements a Map<String,Parameter>, so you can use this to get/put parameters to the map.

The most interesting is a Parameter interface that has implementations Parameter.Empty, Parameter.File, Parameter.Request. The last one is used to retrieve request parameters.

This answer How could I get a parameter in JSP will throw a light on a typical usage of request parameters if you want to manipulate parameters manually.

Another approach (which is not recommended) is to get request parameters from the request itself. See Interceptors use in login in Struts 2.0.



来源:https://stackoverflow.com/questions/45296712/changing-parameteraware-to-httpparametersaware

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