站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2EE 专题简单的javabean 页面却调不出来,各位大虾帮帮忙,小弟先谢!!!!!!!!

简单的javabean 页面却调不出来,各位大虾帮帮忙,小弟先谢!!!!!!!!

摘要: 简单的javabean 页面却调不出来,各位大虾帮帮忙,小弟先谢!!!!!!!!


bean代码:

public class test
{
public int a=0;
public void say()
{
System.out.println("a="+a);
}
public test()
{
}
}

编译后放到 /WEB-INF/classes/ 下了




页面调用代码;

<%@ page language="java" import="java.io.*" contentType="text/html;charset=gb2312" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


My First Sample JSP!
<body>
<form name="f1" action="checkUser.jsp" method="post">
<table width="60%" align="center">
<tr align=center>
<td>



风荷曲园家庭管理系统

</td>
</tr>
<tr align=center>
<td><input type="input" name="username"></td>
</tr>
<tr align=center>
<td><input type="password" name="userpassword"></td>
</tr>
<tr>
<td align=center><input type="submit" value="提交" onclick="return checkform();"> <input type="button" value="重置" onclick="f1.reset();"></td>
</tr>
</table>
</form>
<body>

<script language="JavaScript">
function checkform(){
if(f1.username.value==""){
alert("请输入用户名!");
f1.username.focus();
return false;
}
if(f1.userpassword.value==""){
alert("请输入密码!");
f1.userpassword.focus();
return false;
}
f1.submit();
}
</script>



错误提示:

type Exception report

message

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

exception

org.apache.jasper.JasperException: /wgh/login.jsp(2,0) The value for the useBean class attribute test is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1227)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.



为什么报错误啊,帮帮忙,和环境变量设置有关系吗??



public test()
{
}
===============
返回的类型呢?至少也该是void吧?


当我没说,呵呵,没看清楚,呵呵!!!


构造函数,帮我看看,是怎么回事


在线等 ,顶


bean的包最好放在package里,否则在不同的容器里可能会有问题,给test.java加个package试试


我试试。。。


还是不行啊,怎么回事
package sample;




怎么编译的javac sample/test.java


你在也面上引那个javabean了吗?


你引一下看看


<%@ page import="javabean的全路径"%>


编译是这么编译的, javac -d . test.java


<%@ page import="sample.test" %>

报错:
Generated servlet error:
D:/tomcat5.5/work/Catalina/localhost/webRoot/org/apache/jsp/wgh/login_jsp.java:7: package sample does not exist
import sample.test;
^
1 error

我是我classes/sample/test.class 有啊,郁闷了


编译的时候把包也带进去,这个问题我已经说了很多次,这是最后一次呵呵
在WEB-INF/classes/目录下运行,javac sample/test.java,这是最原始的做法,等到你领悟了更高深的武功,就会觉得这样很傻


好了,不是那个编译的问题,找到原因了,是连接池设置的问题,谢谢
titaninwinter(梦里花落)

结贴了,给分


fgdg


↑返回目录
前一篇: 表单提交中文乱码问题,急。。。
后一篇: 求教什么是JDNI一直不理解