jsp页面利用get方式提交到后台的数据为乱码格式的解决办法

来源:互联网 发布:淘宝先锋乒羽商城 编辑:程序博客网 时间:2024/05/22 00:19

java小白一枚,希望各位大佬多多指点

这是这两天写的一个分页查询跟模糊查询,这篇文章的主题是标红部分,这个值一传到后台就是乱码

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%> 
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
<!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">
<title>${u.username }</title>
</head>
<body><center><h1>总页面</h1><h1>欢迎<font color="red">${u.username }</font>先生</h1>
<form action="show" method="post">
电影类型:<input type="text" name="type" size="2px">
上映时间:<input type="text" name="date" size="2px">
<input type="submit" value="查询">
<input type="button" value="添加" onclick="location.href='addUI'">
</form>
<table border="1px">
<tr>
<th>电影姓名</th>
<th>电影类型</th>
<th>电影时间</th>
<th>上映时间</th>
<th>用户评价</th>
<th>操作</th>
</tr>
<c:forEach items="${list.list}" var="m">
<tr>
<th>${m.mname }</th>
<th>${m.mtype}</th>
<th>${m.datee }</th>
<th>${m.date }</th>
<th>${m.grade }</th>
<th>
<input type="button" value="删除" onclick="location.href='dele?id=${m.id}'">
<input type="button" value="修改" onclick="location.href='updateUI?id=${m.id}'">
</th>
</tr>
</c:forEach>
</table>


<input type="button" value="首页" onclick="location.href='show?pagenum=${list.firstPage}&type=${list.type }'">
<c:if test="${list.pageNum>1}">
<input type="button" value="上一页" onclick="location.href='show?pagenum=${list.prePage}&type=${list.type }'">
</c:if>
<c:if test="${list.pageNum<list.lastPage}">
<input type="button" value="下一页" onclick="location.href='show?pagenum=${list.nextPage}&type=${list.type }'">
</c:if>
<input type="button" value="尾页" onclick="location.href='show?pagenum=${list.lastPage}&type=${list.type }'">
共${list.lastPage }页
<form action="show" method="post">
<input type="submit" value="跳到"><input type="text" size="1px" name="pagenum">页
</form>
</center>
</body>
</html>

解决办法:

找到 tomcat下边的conf文件

编辑 server.xml 

往里边加一行 URIEncoding="UTF-8"

就OK啦。


阅读全文
1 0