在我正在使用的环境(Tomcat 6)中,路径段中的百分比序列显然在映射到@PathVariable时使用ISO-8859-1进行解码.
我希望它是UTF-8.
我已经将Tomcat配置为使用UTF-8(使用server.xml中的URIEncoding属性).
Spring/Rest是自己进行解码吗?如果是,我可以在哪里覆盖默认编码?
附加信息; 这是我的测试代码:
@RequestMapping( value = "/enc/{foo}", method = RequestMethod.GET )
public HttpEntity<String> enc( @PathVariable( "foo" ) String foo, HttpServletRequest req )
{
String resp;
resp = " path variable foo: " + foo + "\n" +
" req.getPathInfo(): " + req.getPathInfo() + "\n" +
"req.getPathTranslated(): " + req.getPathTranslated() + "\n" +
" req.getRequestURI(): " + req.getRequestURI() + "\n" +
" req.getContextPath(): " + req.getContextPath() + "\n";
HttpHeaders headers = new HttpHeaders();
headers.setContentType( new MediaType( "text", …Run Code Online (Sandbox Code Playgroud)