我们从前台页面传递参数到后台,经常会遇到乱码问题!!
例子:
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <%--<form action="http://localhost:8080/SpringMVC_05/e/t" method="post">--%> <form action="${pageContext.request.contextPath}/e/t" method="post"> <input type="text" name="name"> <input type="submit"> </form> </body> </html>
@PostMapping("/e/t") public String test3( String name, Model model){ model.addAttribute("msg",name); return "test1"; }
测试结果:
解决办法如下: