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

javaBean使用有关问题,没有转到welcome页面,

2013-09-11 
javaBean使用问题,没有转到welcome页面,急!错误信息:org.apache.jasper.JasperException: Unable to compi

javaBean使用问题,没有转到welcome页面,急!
错误信息:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 20 in the jsp file: /welcome.jsp
Generated servlet error:
The method print(boolean) in the type JspWriter is not applicable for the arguments (void)


org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
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)


register.jsp如下:
<%@ page language="java" contentType="text/html; charset=gbk"
  pageEncoding="gbk"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>模拟注册</title>
</head>

<body>
  <form name="form1" method="post" action="welcome.jsp">
  <p>班级:
  <input name="class" type="text" size="20">
  </p>
  <p>学号:
  <input name="number" type="text" size="20" maxlength="20">
  </p>
  <p>姓名:
  <input name="name" type="text" size="15" maxlength="15">
  </p>
  <p>籍贯:
  <input name="address" type="text" size="20" maxlength="20">
  </p>
  <p>爱好:
  <input name="hoby" type="text" size="15" maxlength="15">
  </p>
  <p>
  <input type="submit" name="Submit" value="提交">
  </p>
  </form>
</body>
</html>

welcom.jsp如下:
<%@ page language="java" contentType="text/html; charset=gbk"
  pageEncoding="gbk"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="bean.Student" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>欢迎页面</title>
</head>
<body>
 <%!String getClass,getName,getAddress,getNumber,getHoby;%>
  <%
  getClass = request.getParameter("class");
  getNumber =request.getParameter("number");
  getName = request.getParameter("name");
  getAddress = request.getParameter("address");
  getHoby = request.getParameter("hoby");
  %>
<jsp:useBean id="SS" scope="session" class="bean.Student"></jsp:useBean>
<%=SS.setClassName("ahhh")%>
<p align="center"><%=getName%>你好!恭喜你已经注册成功!
</p>
<form name="form1" method="post" action="display.jsp">
  <div align="center">
  <input type="submit" name="back" value="返回主页" >  
  <input type="submit" name="check" value="查看注册信息" >
   


  </div>
</form>
</body>
</html>
下面是javaBean
package bean;

public class Student {
public String className,name,number,address,hoby;

public Student() {
super();
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}



public String getHoby() {
return hoby;
}

public void setHoby(String hoby) {
this.hoby = hoby;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getNumber() {
return number;
}

public void setNumber(String number) {
this.number = number;
}

public String getClassName() {
return className;
}

public void setClassName(String className) {
this.className = className;
}
}





[解决办法]
<%!String getClass,getName,getAddress,getNumber,getHoby;% > 
这句貌似有问题
[解决办法]
你register.jsp里的class和javaBean 里的className没对应上吧...
把你javaBean 里的className改为class看看
[解决办法]
<%=SS.setClassName("ahhh")% > 改成<%SS.setClassName("ahhh")% > ?
[解决办法]
你好象喜欢在%加个空格再加>
<%!String getClass,getName,getAddress,getNumber,getHoby;% >
应为 
<%!String getClass,getName,getAddress,getNumber,getHoby;%> 
你的BEAN的格式好象不是很常见哦 代码不规范
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html

热点排行