我用eclipse3.3+myeclipse6+tomcat5.5写了这个中文字符转换的jsp.输入姓名后点提交却出错~JSP程序源代码:<%@ page contentType="text/html; charset=gb2312" %><%!
public String codeToString(String str)
{//处理中文字符的函数
String s=str;
try
{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
cath(Exception e)
{
return s;
}
}
%><html>
<body>
<form action="chineseStringExample1.jsp" name="form1" method="post">
请输入你的姓名:
<input type="text" name="username">
<input type="submit" name="submit" value="提交">
</form>
<br>
<%
if(request.getParameter("username")==null)
out.println("你没有输入姓名!");
else
out.println("你的姓名为:"+codeToString(request.getParameter("username")));
%>
</body>
</html>
点提交后浏览器错误信息:
HTTP Status 404 - /WebRoot/chineseStringExample1.jsp--------------------------------------------------------------------------------type Status reportmessage /WebRoot/chineseStringExample1.jspdescription The requested resource (/WebRoot/chineseStringExample1.jsp) is not available.
--------------------------------------------------------------------------------Apache Tomcat/5.5.23
public String codeToString(String str)
{//处理中文字符的函数
String s=str;
try
{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
cath(Exception e)
{
return s;
}
}
%><html>
<body>
<form action="chineseStringExample1.jsp" name="form1" method="post">
请输入你的姓名:
<input type="text" name="username">
<input type="submit" name="submit" value="提交">
</form>
<br>
<%
if(request.getParameter("username")==null)
out.println("你没有输入姓名!");
else
out.println("你的姓名为:"+codeToString(request.getParameter("username")));
%>
</body>
</html>
点提交后浏览器错误信息:
HTTP Status 404 - /WebRoot/chineseStringExample1.jsp--------------------------------------------------------------------------------type Status reportmessage /WebRoot/chineseStringExample1.jspdescription The requested resource (/WebRoot/chineseStringExample1.jsp) is not available.
--------------------------------------------------------------------------------Apache Tomcat/5.5.23
我的工程的目录就建的是tomcat下的webapps\WebRoot下,不打WebRoot路径不对直接就显示不出来网页???
你tomcat webapps\有什么
Webapps下有.myeclipse jsp-examples ROOT src tomcat-docs webdav WebRoot这些文件夹,还有.classpath .classpath .project 我真的感觉是一用request.getParameter就出问题~~~其他页面都好好的~~~
无语了你的工作空间怎么在webapps/下应该在其他地方在部署过去