mvc重定向带中文参数乱码问题

首先一种说法是:在传递的时候编码,接收的时候解码

java.net.URLEncoder.encode(str,"UTF-8");

java.net.URLDecoder.decode(str,"UTF-8");

也就是这样,这种在本地测的时候,获取的str是中文的,没有乱码,但是放在正式服务器上又出现乱码的问题

另一种说法:

org.springframework.web.servlet.mvc.support.RedirectAttributes

redirectAttributes.addFlashAttribute("str", "测试");

这样的重定向后的中文参数就正常了,第一种写法目前没有搞明白怎么回事

猜你喜欢

转载自blog.csdn.net/qq_38058332/article/details/88556669
今日推荐