日期:2014-05-18  浏览次数:20692 次

大家看看我的JSP程序错在哪里
//java程序     classes/ch01/Guest.java
package   ch01;
public   class   Guest
{
                  private   String   name;
public   Guest(){ name=null;}
public   void   setName(String   name){ this.name=name;}
public   String   getName(){ return   name;}
}

************demo05.jsp**************
<%@   page   contentType= "text/html;   charset=gb2312 "%>
<%@   page   import= "ch01.* "%>
<jsp:useBean   id= "guest "   scope= "session "   class= "ch01.Guest ">
<jsp:setProperty   name= "guest "   property= "* "/>
</jsp:useBean>
<%
      if(request.getParameter( "name ")!=null){
              response.sendRedirect( "response.jsp ");
}
%>
<html>
<head>
      <title> 你好,客人 </title>
</head>
<body>
      <h1> 嗨,你好.我叫cf,你呢? </h1> <br>
      <hr>
      <form   action= "demo05.jsp "   method= "get ">

      <input   type= "text "   name= "name "   size= "25 ">       //输入到guest.name中

      <input   type= "submit "   value= "提交 ">
      <input   type= "reset "   value= "重置 ">
      </form>
</body>
</html>

************response.jsp************
<%@   page   contentType= "text/html;   charset=gb2312 "%>
<jsp:useBean   id= "guest "   scope= "session "   class= "ch01.Guest "/>

<html>
<head>
        <title> 响应页 </title>
</head>
<body>
    <br>
    <h1>
          嗨,你好 <%=guest.getName()%> <br>
        嗨,你好 <jsp:getProperty   name= "guest "   property= "name "/   >         ***这是报错误
    </h1>
</body>
</html>


tomcat错误:
org.apache.jasper.JasperException:   /response.jsp(14,51)   Unterminated   &lt;jsp:getProperty   tag
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



------解决方案--------------------
可能时有非法字符

嗨,你好 <jsp:getProperty name= "guest " property= "name "/ >

把这一行的前面的中文换成 英文 然后把前面的空格都去掉
-