我试图通过post请求将数据传递到控制器中,但#
被从值中剥离。我试过HttpRequestUtil.getParametersMap(request)
和@RequestParam("param")
,但似乎都去掉了#
@RequestMapping(value = "/submit", method = RequestMethod.POST)
public String handlerReceiptSinglePost(@RequestParam("bill_to_address_line2") final String billingLine2, final HttpServletRequest request, final Model model)
{
LOG.info(billingLine2);
}
当我使用像这样的表单发布到这个方法时:
<form action="/submit" method="POST">
<input name="bill_to_address_line2" value="#4"/>
</form>
我在日志里看到了这个
INFO [Controller] "4"
spring中有没有什么配置会导致这种情况呢?或者任何我应该检查以进一步排除故障的内容?
发布于 2019-02-28 10:30:27
request.setCharacterEncoding("UTF-8");
使用编码请求来支持您的帖子值中的特殊字符请查看此博客https://www.programcreek.com/java-api-examples/?class=javax.servlet.http.HttpServletRequest&method=setCharacterEncoding
https://stackoverflow.com/questions/54916901
复制相似问题