Glassfish solves garbled characters when receiving requests on the SpringMVC server. glassfishspringmvc
Environment Description
Front-end: jsp
Backend: SpringMVC Controller
Although pageEncoding has been set on the jsp page:
<% @ Page contentType = "text/html" pageEncoding = "UTF-8" %>
Then, in the controller, if the corresponding read parameter contains Chinese characters, garbled characters appear, for example:
Public ModelAndView search (@ RequestParam ("keyword") String keyword) {// garbled keyword}
Solution
Create an xml file named "glassfish-web" and add the following code:
<? Xml version = "1.0" encoding = "UTF-8"?> <Glassfish-web-app> <parameter-encoding default-charset = "UTF-8"/> </glassfish-web-app>
Save to/WEB-INF directory.
Reference: http://stackoverflow.com/questions/25870583/glassfish-spring-not-correctly-decoding-utf-8-in-post