(jsp和servlet高手请进)jsp里调不出servlet的值,来救救我吧!!5555555555555555

8586648 2004-04-23 09:08:56
老兄你好:我写的程序从servlet里向jsp传值,tomcat抱错: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] Compiling 1 source file [javac] C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\tt\hys_jsp.java:42: cannot resolve symbol [javac] symbol : class Operator_T [javac] location: interface javax.servlet.Servlet [javac] Servlet.Operator_T data = null; [javac] ^ [javac] C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\tt\hys_jsp.java:44: cannot resolve symbol [javac] symbol : class Operator_T [javac] location: interface javax.servlet.Servlet [javac] data = (Servlet.Operator_T) pageContext.getAttribute("data", PageContext.REQUEST_SCOPE); [javac] ^ [javac] 2 errors 这是怎么回事 我的qq是65671445 帮帮忙吧 先谢谢了!!!
...全文
22 点赞 收藏 16
写回复
16 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
yaray 2004-04-27
这两个编译后的类文件应放在WEB-INF\classes\Servlet\目录下(注意目录名大小写要与包名一致)

你的Servlet(就是你的Operator_Servlet类)还要在web.xml文件配置相应的映射才能使用.
回复
viano 2004-04-27
Operator_T 是class 文件!
回复
viano 2004-04-27
你的 useBean 有问题!

<jsp:useBean id="data" scope="request" class="Servlet.Operator_T" />
<jsp:setProperty name="data" property="*"/>


这样就好了!

回复
8586648 2004-04-26
我放在/servlet下了!!
回复
jinsfree 2004-04-26
你的Opertor_T.class 放在哪里?
回复
AbnerChai 2004-04-24
<jsp:useBean id="data" type="Servlet.Operator_T" scope="request">
有问题,不是type是class
回复
8586648 2004-04-24
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*,Servlet.Operator_T"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<jsp:useBean id="data" type="Servlet.Operator_T" scope="request">
<jsp:getProperty name="data" property="*"/>
</jsp:useBean>
<%
//data=request.getAttribute(data);
//data=pageContext.getAttribute("data", PageContext.REQUEST_SCOPE);
//Operator_T data=new Operator_T();
//<jsp:useBean id="data" type="Servlet.Operator_T" scope="request">
//<jsp:getProperty name="data" property="*"/>
//</jsp:useBean>
java.util.Vector login=data.getVlogin();
ava.util.Vector name=data.getVname();
java.util.Vector dept=data.getVdept();
java.util.Vector password=data.getVpassword();
java.util.Vector code=data.getVcode();
String strlogin="";
String strname="";
String strdept="";
String strpassword="";
String strcode="";
%>
<body>
<form name="form1" method="post" action="">
<table width="793" border="0">
<tr>
<td>login</td>
<td>cname</td>
<td>cdept</td>
<td>pws</td>
<td>code</td>
</tr>
<%
for(int i=0;i<login.size();i++){
strlogin=(String)login.elementAt(i);
strname=(String)name.elementAt(i);
strdept=(String)dept.elementAt(i);
strpassword=(String)password.elementAt(i);
strcode=(String)code.elementAt(i);
%>
<tr>
<td><%=strlogin%></td>
<td><%=strname%></td>
<td><%=strdept%></td>
<td><%=strpassword%></td>
<td><%=strcode%></td>
</tr>
<% } %>
</table>
</form>
</body>
</html>
回复
8586648 2004-04-24
package Servlet;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.PrintWriter;
import java.sql.*;
import java.util.*;
import java.text.*;
import java.lang.*;
public class Operator_Servlet extends HttpServlet{
Operator_T data=new Operator_T();
private ConnectBean cb;
private ResultSet rs;
private PreparedStatement ps=null;
private Vector vector=new Vector();
public Vector getData(){
return vector;
}
PrintWriter out;
public void doPost(HttpServletRequest req,HttpServletResponse resp)throws ServletException,java.io.IOException{
req.setCharacterEncoding("gb2312");
resp.setContentType("text/html; charset=gb2312");
out=resp.getWriter();
try{
if(req.getParameter("rygl")!=null&&req.getParameter("rygl").equals("rygl")){
try{
queryData(data);
String strcall = "/tt/hys.jsp";
req.setAttribute("data",data);
callJSP(req, resp, strcall);
}
catch(Exception ena){
System.out.println(ena);
out.println(ena);
}
}
}
catch(Exception esn){
System.out.println(esn);
out.println(esn);
out.println("数据库操作失败!!!");
}
}
public void doGet(HttpServletRequest req,HttpServletResponse resp)throws ServletException,java.io.IOException{
doPost(req,resp);
}
}
public void callJSP(HttpServletRequest request, HttpServletResponse response, String url)throws Exception {
try {
ServletContext sc = getServletConfig().getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(request, response);
} catch (Exception e) {
throw e;
}
}
public void queryData(Operator_T data) throws SQLException{
Vector vlogin=null;
Vector vname=null;
Vector vdept=null;
Vector vpassword=null;
Vector vcode=null;
cb=new ConnectBean();
if(!cb.openConnection()){
System.out.println ("连接错误");
}
String query="Select * From OPERATOR";
System.out.println (query);
try{
cb.createPreparedStatement(query);
rs=cb.executeQuery();
vlogin=new Vector();
vname=new Vector();
vdept=new java.util.Vector();
vpassword=new java.util.Vector();
vcode=new java.util.Vector();
while(rs.next()){
vlogin.add((rs.getString(1) == null) ? "" : (rs.getString(1)).trim());
vname.add((rs.getString(2)==null)?"":(rs.getString(2)).trim());
vdept.addElement((rs.getString(3)==null)?"":(rs.getString(3)).trim());
vpassword.addElement((rs.getString(4)==null)?"":(rs.getString(4)).trim());
vcode.addElement((rs.getString(5)==null)?"":(rs.getString(5)).trim());
vector.add(data);
}
data.setVlogin(vlogin);
System.out.println(vlogin);
data.setVname(vname);
System.out.println(data.getVname());
data.setVdept(vdept);
System.out.println(vdept);
data.setVpassword(vpassword);
System.out.println(data.getVpassword());
data.setVcode(vcode);
System.out.println(data.getVcode());
rs.close();
ps.close();
cb.close();
}
catch(Exception esn){
System.out.println (esn);
System.out.println("xpxpxpxpxpxpxxxpxpxpx");
}

}

}
回复
8586648 2004-04-24
package Servlet;
import java.util.*;
public class Operator_T{
private String login,name,dept,password,code;
private Vector vlogin,vname,vdept,vpassword,vcode;

//Operator_T data=new Operator_T();
public Operator_T() {
}
public void setLogin(String login){
this.login=login;
}
public String getLogin(){
return login;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setDept(String dept){
this.dept=dept;
}
public String getDept(){
return dept;
}
public void setPassword(String password){
this.password=password;
}
public String getPassword(){
return password;
}
public void setCode(String code){
this.code=code;
}
public String getCode(){
return code;
}
public void setVlogin(Vector vlogin){
this.vlogin=vlogin;
}
public Vector getVlogin(){
return vlogin;
}
public void setVname(Vector vname){
this.vname=vname;
}
public Vector getVname(){
return vname;
}
public void setVdept(Vector vdept){
this.vdept=vdept;
}
public Vector getVdept(){
return vdept;
}
public void setVpassword(Vector vpassword){
this.vpassword=vpassword;
}
public Vector getVpassword(){
return vpassword;
}
public void setVcode(Vector vcode){
this.vcode=vcode;
}
public Vector getVcode(){
return vcode;
}
}
回复
fu80008 2004-04-24
你需要配置servlet的运行环境.
classpath中加入servlet-api.jar(在tomcat下的lib文件夹下)
在web.xml配置就可以运行了!
回复
8586648 2004-04-24
class也不对 我试过了
回复
8586648 2004-04-24
class也不对啊!!!我都试过了
回复
luckybeggar 2004-04-23
Operator_T重点查一下,不贴代码看不出问题,好像还和接口有关interface?搞不懂类名对吗,包名对吗,放到该放的目录下了吗,重启Tomcat呢?太多可能,搞不懂
回复
ddbean 2004-04-23
你没有import:Operator_T类, 或者Operator_T所在的package不对
回复
yaray 2004-04-23
hys.jsp中:
cannot resolve symbol [javac] symbol : class Operator_T
Operator_T data = null;
^^^^^^^^^^是什么?是否import? 如果是在同一个包中,则先编译Operator_T。
回复
jinsfree 2004-04-23
Operator_T ,此类找不到
具体贴出代码
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-04-23 09:08
社区公告
暂无公告