首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

大家看看小弟我的JSP程序错在哪里

2012-01-16 
大家看看我的JSP程序错在哪里//java程序classes/ch01/Guest.javapackagech01publicclassGuest{privateStr

大家看看我的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 "/ >

把这一行的前面的中文换成 英文 然后把前面的空格都去掉
[解决办法]
你在setProperty没有初始话JAVABEAN
[解决办法]
同意interpb(曾曾胡,深怕情多累美人!)
<jsp:getProperty name= "guest " property= "name "/ > 估计在最后有全角字符


[解决办法]
嗨,你好 <jsp:getProperty name= "guest " property= "name "/ >

/后面多了一个空格

还有 你这么做根本得不到form传来的数据,因为你没set
[解决办法]
demo05

<%@ page contentType= "text/html; charset=gb2312 "%>
<%@ page import= "csdn02.* "%>
<jsp:useBean id= "guest " scope= "session " class= "csdn02.Guest "/>
<%
if(request.getParameter( "name ")!=null){%>
<jsp:setProperty name= "guest " property= "name " value= " <%=request.getParameter( "name ")%> "/> //多了他!!
<%
response.sendRedirect( "jsp2.jsp ");
}
%>
<html>
<head>
<title> 你好,客人 </title>
</head>
<body>
<h1> 嗨,你好.我叫cf,你呢? </h1> <br>
<hr>
<form action= "jsp1.jsp " method= "get ">
<input type= "text " name= "name " size= "25 ">
<input type= "submit " value= "提交 ">
<input type= "reset " value= "重置 ">
</form>
</body>
</html>
[解决办法]
同意楼上的,(dr_lou())

热点排行