我的第一个JSP程序,出错,请大家帮忙看看

panzi667 2004-09-07 11:08:41
我浏览页面的时候就出现问号,其实那些问号应该是中文字符

Hello, world!????????JSP??




源程序
<%@ page session=false %>
<%
//
// Scripts between the scriptlet tags are simply executed.
//
String title = "Hello, world!这是我改的第一个JSP程序";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<!-- The expression tags interpolate script variables into the HTML -->

<title><%= title %></title>
</head>

<body bgcolor=white>

<h1><%= title %></h1>

</body>
...全文
86 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
panzi667 2004-09-08
  • 打赏
  • 举报
回复
谢谢,问题解决咯
skymark126 2004-09-07
  • 打赏
  • 举报
回复
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%
String title = "Hello, world!这是我改的第一个JSP程序";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=title%></title>
</head>

<body bgcolor=white>

<h1><%=title%></h1>

</body>


不好意思!
这样就行了!
不用去转换!
xiangbo520 2004-09-07
  • 打赏
  • 举报
回复
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
你加了这个以后就不要再多此一举的来title=strtochin(title);这个转换了。
panzi667 2004-09-07
  • 打赏
  • 举报
回复
还是不行


<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%
//
// Scripts between the scriptlet tags are simply executed.
//
String title = "Hello, world!这是我改的第一个JSP程序";
title=strtochin(title);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<!-- The expression tags interpolate script variables into the HTML -->

<title><%= title %></title>
</head>

<body bgcolor=white>

<h1><%= title %></h1>

</body>
<%!
String strtochin(String str)
{
byte[] byte1=str.getBytes();
String temp="";
try
{
temp=new String(byte1,"iso-8859-1");
}
catch(Exception e){
}
return temp;
}
%>



skymark126 2004-09-07
  • 打赏
  • 举报
回复
不行啊!
这样:
<%!
String strtochin(String str)
{
byte[] byte1=str.getBytes();
String temp="";
try
{
temp=new String(byte1,"iso-8859-1");
}
catch(Exception e){
}
return temp;
}
%>

加上它;并且将String title = "Hello, world!这是我改的第一个JSP程序";
写为:String title = "Hello, world!这是我改的第一个JSP程序";
title=strtochin(title);

试试!希望行!!
panzi667 2004-09-07
  • 打赏
  • 举报
回复
对咯,我装的JSP的web引擎为RESIN(resin-2.1.14)
skymark126 2004-09-07
  • 打赏
  • 举报
回复
<%@ page contentType="text/html; charset=gb2312" language="java" %>
把它加上就行了!
panzi667 2004-09-07
  • 打赏
  • 举报
回复
加咯,还是不行
bluedream2003 2004-09-07
  • 打赏
  • 举报
回复
在第一行加入
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
panzi667 2004-09-07
  • 打赏
  • 举报
回复
自己第一个UP

81,092

社区成员

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

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