2017-04-21 15:53 GMT+02:00 Burton Rhodes <burtonrho...@gmail.com>: > Since the invocation.getInvocationContext().getParameters().toMap() method > is now deprecated, how would I refactor my String Trim interceptor to trim > incoming parameters? The HttpParameters parameter objects are designed to > be "immutable". Some posts online have suggested type converters, but > seems like this is the perfect use for an interceptor. > > My trim interceptor code is below... > > protected String doIntercept(ActionInvocation invocation) throws Exception { > Map<String, String[]> parameters = > invocation.getInvocationContext().getParameters().toMap(); > for (String param : parameters.keySet()) { > if (isIncluded(param)) { > String[] values = parameters.get(param); > for (int i = 0; i < values.length; i++) { > values[i] = values[i].trim(); > } > } > } > > return invocation.invoke(); > }
HttpParameters httpParameters = HttpParameters.create(parameters).build(); invocation.getInvocationContext().setParameters(htttpParameters); this should work. Regards -- Ćukasz + 48 606 323 122 http://www.lenart.org.pl/ --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org