Tomcat / Spring - get parameters not decoded

For some reason, my Tomcat / Spring config does not automatically decrypt the GET parameters (I assume this should be done automatically).

Here's my setup:

@RestController
public class MyController {
    @RequestMapping(value = "/do-something", method = RequestMethod.GET)
    public String doSomething(RequestPojo req) {
        // req.getPhone -- is not decoded, ie might be something like 00%204 instead of 004
    }
}


public class RequestPojo {
    private String phone;
    // getter and setter
}

      

Here is the content of mvc-dispatcher-servlet:

<mvc:default-servlet-handler/>
<mvc:annotation-driven>
    <mvc:message-converters register-defaults="false">
        <ref bean="customJsonHttpMessageConverter"/>
    </mvc:message-converters>
</mvc:annotation-driven>
<context:component-scan base-package="com.onoff.controller">
    <context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>

<bean id="multipartResolver" name="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize" value="1073741824"/>
    <property name="defaultEncoding" value="utf8"/>
</bean>

<bean id="customJsonHttpMessageConverter" class="com.onoff.util.CustomJsonHttpMessageConverter">
    <property name="supportedMediaTypes" value="application/json; charset=utf-8"/>
</bean>

      

I checked some suggestions before posting. URIEncoding="UTF-8"

specified in the server.xml file in Tomcat.

Any hints? Any help / suggestions would be much appreciated.

Thanks in advance.

+3


source to share


1 answer


Try with @ModelAttribute



public String doSomething (@ModelAttribute RequestPojo req) {
        // req.getPhone - is not decoded, ie might be something like 00% 204 instead of 004
    }
0


source







All Articles