Glassfish在SpringMVC服务端接收请求时字符出现乱码的解决办法_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:23:52
Original
1487 people have browsed it

环境描述

前端:jsp

后端:SpringMVC Controller

 

尽管jsp页面已设置了pageEncoding:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
Copy after login

然后在控制器中,读取到的对应参数如果含有中文,则出现乱码,例如:

public ModelAndView search(@RequestParam("keyword") String keyword) {    //keyword乱码    }
Copy after login

解决办法

新建xml文件名为“glassfish-web”,添加以下代码:

<?xml version="1.0" encoding="UTF-8"?><glassfish-web-app>    <parameter-encoding default-charset="UTF-8" /></glassfish-web-app>
Copy after login

保存至 /WEB-INF 目录下即可。

 

参考链接:http://stackoverflow.com/questions/25870583/glassfish-spring-not-correctly-decoding-utf-8-in-post

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template