从JSP传递的中文,在eclipse日志中显示乱码
JSP的主要代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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">
<link rel="stylesheet"
href="${pageContext.request.contextPath}/static/bootstrap3/css/bootstrap.min.css">
<link rel="stylesheet"
href="${pageContext.request.contextPath}/static/bootstrap3/css/bootstrap-theme.min.css">
<link rel="stylesheet"
href="${pageContext.request.contextPath}/static/css/blog.css">
<script
src="${pageContext.request.contextPath}/static/bootstrap3/js/jquery-1.11.2.min.js"></script>
<script
src="${pageContext.request.contextPath}/static/bootstrap3/js/bootstrap.min.js"></script>
<title>新增板块信息</title>
<style type="text/css">
body {
padding-top: 10px;
padding-bottom: 40px;
}
.service {
text-align: center;
}
.breadcrumb>li+li:before {
padding: 0 5px;
color: black;
content: ">\00a0";
}
</style>
</head>
<body>
<div class="container">
<!-- 顶部内容 -->
<%@ include file="/admin/include/top.jsp"%>
<!-- 页面导航内容 -->
<div class="row" id="banner">
<div class="col-md-10">
<ol class="breadcrumb ">
<li><a href="#">系统</a></li>
<li><a
href="${pageContext.request.contextPath}/admin/main.jsp">首页</a></li>
<li><a
href="${pageContext.request.contextPath}/admin/Plate/pindex.jsp">板块管理</a></li>
<li><a href="#">新增板块信息</a></li>
</ol>
</div>
<div class="col-md-2 " style="text-align: right;">
<a
href="${pageContext.request.contextPath}/admin/Plate/addPlate.jsp"><button
class="btn btn-default">新增板块信息</button></a>
</div>
</div>
<hr>
<!-- 中间内容 -->
<div class="row" id="content">
<div class="col-md-12">
<form class="form-inline" action="${pageContext.request.contextPath}/admin/plate/addPlate.do">
<div class="form-group">
板块名称: <input type="text" class="form-control"
id="plateName" name="plateName">
</div>
<button type="submit" class="btn btn-default">保存</button>
</form>
</div>
</div>
<!-- 底部内容 -->
<%@ include file="/admin/include/footer.jsp"%>
</div>
</body>
</html>
问题原因:
jsp的form中缺少method属性,默认使用的是get,而get处理中文时会乱码
解决方法:JSP的form添加属性 method="post"
<form class="form-inline" action="${pageContext.request.contextPath}/admin/plate/addPlate.do" method="post">