用jsp传中文,第一次可以,再点就不行了。求解,啊,来拯救我吧
这是我的代码,下边的搜索框,点击可以搜索到中文。我做的真分页,点下一页就传不过去中文了。变成?了,。试了好多方法大神拯救我吧程序代码:
<%@ page language="java" import="java.util.*" contentType="text/html; charset=GBK" pageEncoding="GBK"%> <%@ page import="dao.dao.*"%> <%@ page import="dao.dao.factory.*"%> <%@ page import="dao.vo.*"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'select.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <script language="javascript" src="js/select.js"></script> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("UTF-8"); int currentPage = 1; int pageSize = 10; int recoderCount = 0; int pageCount = 0; List all = null; String keyword = ""; if(request.getParameter("keyword")!=null&&request.getParameter("keyword")!=""){ keyword = request.getParameter("keyword"); } if (request.getParameter("currentPage") != "" && request.getParameter("currentPage") != null) { try { currentPage = Integer.parseInt(request .getParameter("currentPage")); if(currentPage<1){ currentPage = 1; } } catch (Exception e) { throw e; } } %> <table borber=1 align="center"> <tr> <td> 新闻编号 </td> <td width="70" height="5"> 新闻标题 </td> <td width="500" align="center"> 新闻内容 </td> <td align="center"> 新闻类型 </td> <td> 修改 </td> <td> 删除 </td> </tr> <% INewsDAO dao = DAOFactory.getINewsDAOInstance(); all = dao.findAll(currentPage, pageSize,keyword); recoderCount = dao.getAllCount(keyword); pageCount = recoderCount / pageSize+1; Iterator str = all.iterator(); while (str.hasNext()) { News news = (News) str.next(); %> <tr> <td><%=news.getNewsid()%></td> <td width="50"><%=news.getNewstitle()%></td> <td width="500"><%=news.getNewscount()%></td> <td align="center"><%=news.getNewstype()%></td> <td> <a href="news/dmi!select?id=<%=news.getNewsid()%>">修改</a> </td> <td> <a href="news/dmi!delete?id=<%=news.getNewsid()%>">删除</a> </td> </tr> <% } if(currentPage>pageCount){ %>对不起您输入的页码大于最大页码<% } %> <tr> <td></td> <td></td> <td></td> <td align="right"> <a href=news/select.jsp?currentPage=1&keyword=<%=keyword%>>首页</a> <% if(currentPage<3){ currentPage = 3; } for(int i=currentPage-2;i<=currentPage+2&&i<=pageCount;i++){ if(i<1){ i=0; continue; } %> <a href=news/select.jsp?currentPage=<%=i %>&keyword=<%=keyword %>><%=i %></a> <% } %> <a href=news/select.jsp?keyword=<%=keyword%>¤tPage=<%=pageCount%>>尾页</a> <form action="news/select.jsp" name="select" method="post" onSubmit="return check()"> <input type=text name="currentPage" size="5"> <input type="hidden" name="keyword" value=""> <input type=submit value="跳转"> </form> </td> </tr> </table> <a href="news/dmi"></a> <br /> <a href="news/add.jsp">添加</a> <br /> <br /> 有<%=recoderCount%>条记录 <br /> 有<%=pageCount%>页 <br /> <br /> <form action="news/select.jsp" method="post"> <input type="text" name="keyword"> <input type="submit" value="搜索"><!-- 搜索框在这里 --> </form> <br /> <%=keyword %>qq123sdffdggdd <br /> <a href="max/MyJsp.jsp">计算器</a> </body> </html>