tag中输出中文的问题

zhaoxichao 2002-01-22 12:53:12
1.jsp中有
<%@ taglib uri="taglib.tld" prefix="test" %>
<html>
<head>
<title>
ExampleView
</title>
</head>
<body>
<h1>
<font size="2">
<test:index/><br>
</h1>
</body>
</html>
indexTag.java为
string[] indexList;
pageContext.getOut().print("<p>"+indexList[i]+"</p>");
如果indexList为中文,在jsp出现的就是??,英文没有问题,怎么回事?怎么解决?
...全文
46 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ligyi 2002-01-22
  • 打赏
  • 举报
回复
jsp处理中文是有问题;可以再加上<%@page language="java" contentType="text/html;charset=gb2312" %>
这样可以解决在jsp中中文问题。
如实传过来的中文参数:可以用下面的函数解决:
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
}
return "null";
}
用法如下:
String name=getStr(request.getParameter("name"));

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧