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();
}

Thanks!

Reply via email to