日期:2014-05-20  浏览次数:20615 次

初学JSP 基础问题
小弟初学JSP   遇到一个问题
<%@page   contentType= "text/html;   charset=GBK "   import= "java.io.*; "%>
<html>
<head>
<title> JSP </title>
</head>
<body   bgcolor= "#ffffff ">

<%
String   input=request.getParameter( "txtinput ");
if   (input!=null   &&   !input.equals( " "))
{
    out.println( " <font   color= 'red '> <h3> "+input+ " </h3> </font> ");
}else{
    out.println( " <form   id= 'myform '   name= 'myform '   method= 'post '   action= 'firstjsp.jsp '> ");
    out.println( " <input   name= 'txtinput '   type= 'text '   id= 'txtinput '   /> ");
    out.println( " <input   type= 'submit '   name= 'Submit '   value= '提交 '   /> ");
    out.println( " </form> ");
}

%>
</body>
</html>

上面这个表单   如果我输入数字或者英文字母   可以正常工作。
可是如果我输入汉字   就成了??   这样的了  
我查baidu也查到了好多答案   不过好像都不行
请各位帮忙!   谢谢!

------解决方案--------------------
request.setCharactorEncoding( "gbk ");
------解决方案--------------------
在信息输入页面,输入信息之前写代码
request.setCharactorEncoding( "gbk ");
在信息获取页面,信息获得之前也写上,
应该就可以了