Glassfish solves garbled characters when receiving requests on the SpringMVC server. glassfishspringmvc

Source: Internet
Author: User
Tags glassfish

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.