码迷,mamicode.com
首页 > Web开发 > 详细

<jsp:param>传参乱码问题

时间:2015-05-08 12:41:50      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

在添加参数的界面添加<%request.setCharacterEncoding("UTF-8");%>

实例代码:

login_confirm.jsp

<%@ 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>
<!-- 解决jsp:param传参乱码问题 -->
<%request.setCharacterEncoding("UTF-8");%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>登录验证界面</title>
</head>
<body>
<c:if test="${param.username==\"123\" && param.userpass==\"123456\"}">
<!-- 把用户信息添加到session-->
<c:set var="username" value="${param.username}" scope="session"/>
<jsp:forward page="login_success.jsp"/>
</c:if>

<c:if test="${param.username !=\"123\"}">
<jsp:forward page="login_failure.jsp">
<jsp:param name="info" value="用户名不正确"/>
</jsp:forward>
</c:if>
<c:if test="${param.userpass!=\"123456\"}">
<jsp:forward page="login_failure.jsp">
<jsp:param name="info" value="用户口令不正确"/>
</jsp:forward>
</c:if>

</body>
</html>

login_failure.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">
<title>登录成功界面</title>
</head>
<body>
登录失败,错误信息如下:${param.info}
<div align="center">
    <a href="index.jsp">重新登录</a>
</div>
</body>
</html>

 

<jsp:param>传参乱码问题

标签:

原文地址:http://www.cnblogs.com/anan1688/p/4487100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!