当前位置: 代码迷 >> Java Web开发 >> javabean 的问题
  详细解决方案

javabean 的问题

热度:942   发布时间:2006-05-20 14:30:00.0
javabean 的问题

test1.jsp^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="test1" scope="request" class="com.xh1.test1">
<jsp:setProperty name="test1" property="*" />
</jsp:useBean>
<!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=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
out.println(test1.getUsername()+"与"+test1.getPassword());
%>
<form name="form1" method="post" action="?">
<table width="100%" border="1" cellspacing="0" cellpadding="3">
<tr>
<td>用户名</td>
<td><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>密码</td>
<td><input name="password" type="text" id="password"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>

test1.java^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

package com.ch1;
public class test1
{
private String username;
private String password;
public void setUsername(String username)
{
this.username=username;
}
public void setPassword(String password)
{
this.password=password;
}

public String getUsername()
{
return this.username;
}
public String getPassword()
{
return this.password;
}
}

高手看下是什么问题,JBuilder编绎正常,访问http://localhost:8080/xh1/test1.jsp出现以下错误^^^^^^^^^^^^^^^^^^^^^^^^^^^^

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] C:\Tomcat\work\Standalone\localhost\_\xh1\test1_jsp.java:43: package com.xh1 does not exist
    [javac]       com.xh1.test1 test1 = null;
    [javac]              ^
    [javac] C:\Tomcat\work\Standalone\localhost\_\xh1\test1_jsp.java:45: package com.xh1 does not exist
    [javac]         test1 = (com.xh1.test1) pageContext.getAttribute("test1", PageContext.REQUEST_SCOPE);
    [javac]                         ^
    [javac] C:\Tomcat\work\Standalone\localhost\_\xh1\test1_jsp.java:48: package com.xh1 does not exist
    [javac]             test1 = (com.xh1.test1) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "com.xh1.test1");
    [javac]                             ^
    [javac] 3 errors

[此贴子已经被作者于2006-5-20 14:33:30编辑过]

搜索更多相关主题的帖子: javabean  

----------------解决方案--------------------------------------------------------
你是这个论坛上我看到的第二个这么错的人了,注意,使用外部类的时候,一定要记得用import,比如你的
把<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>改成
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,com.xh1.test1" errorPage="" %>

----------------解决方案--------------------------------------------------------
记得投票的时候给我加油啊!
----------------解决方案--------------------------------------------------------
  相关解决方案