Spring MVC Rest特殊字符(ñ,空格,......)

时间:2017-05-23 15:27:22

标签: java spring spring-mvc

我正在使用Spring MVC开发API REST。在控制器之间进行重定向的想法。我的代码如下:

@Controller
public class CustomController {
    @RequestMapping(value = "/a", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String getA(@RequestParam(value="param1", required=true),
        HttpServletRequest request, RedirectAttributes attributes) {
        attributes.addAttribute("param1", param1);
        return "redirect:/b";
    }

    @RequestMapping(value = "/b", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String getB(@RequestParam(value="param1", required=true),
        HttpServletRequest request) {
        return param1;
    }
}

问题是,如果param1有“ñ”字符,则“/a”映射会获得“ñ”,但在重定向到“/b时},到达编码字符(%F1)。无论如何,如果我直接致电“/b”请求,请获取“ñ”。

我已经尝试 https://stackoverflow.com/a/5928162/1722794 但没有成功。

想法?

0 个答案:

没有答案