后台传数据到前台出现中文乱码解决办法

1.在jsp页面上添加meta属性

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">   <%-- 在IE运行最新的渲染模式 --%>
<meta name="viewport" content="width=device-width, initial-scale=1">   <%-- 初始化移动浏览显示 --%>

2.在controller层添加

/**
	 * 添加修改角色
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/edit",produces = {"application/text;charset=UTF-8"})//加此中文乱码解除
	public String edit(@Param("rid") String rid) throws Exception {

猜你喜欢

转载自blog.csdn.net/weixin_39209728/article/details/84023132
今日推荐