servlet与JSP传值的问题
我在servlet里有一个arraylist,传值到jsp后发现中文都是???。
Java code
RequestDispatcher dis = request.getRequestDispatcher("navi_success.jsp");
request.setAttribute("start_to_jsp",start_to_jsp);
dis.forward(request, response);
navi_success.jsp中
HTML code
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8"%>
...
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
...
<%=request.getAttribute("start_to_jsp")%>
这样显示。只要是中文就显示问号。怎么解决?求高手指导。
另外,如何将这个arraylist里返回的东西在jsp里面变成单选框?有什么好的方法?
------解决方案--------------------你的start_to_jsp变量是一ArrayList????
------解决方案--------------------
页面编码是utf-8,请求和响应也设置为utf-8,这样应该可以了
response.setCharacterEncoding("utf-8"); request.setCharacterEncoding("utf-8"); RequestDispatcher dis = request.getRequestDispatcher("navi_success.jsp");
request.setAttribute("start_to_jsp",start_to_jsp);
dis.forward(request, response);
------解决方案--------------------