当前位置: 技术问答>java相关
还是javabean的问题
来源: 互联网 发布时间:2017-03-13
本文导语: cc.jsp如下: Untitled this is cc.jsp: UserEnv.java内容如下: package test; import java.io.*; public class UserEnv{ private String userdir = ""; private String userurl = ""; public UserEnv(){ userdir="aaa"; System.out.println("init userdir, one time"); }...
cc.jsp如下:
Untitled
this is cc.jsp:
UserEnv.java内容如下:
package test;
import java.io.*;
public class UserEnv{
private String userdir = "";
private String userurl = "";
public UserEnv(){
userdir="aaa";
System.out.println("init userdir, one time");
}
public void setUserDir(String str)
{
userdir=str;
}
public String getUserdir() throws Exception{
return userdir;
}
}
我编译以后在examples下WEB-INFclasses下建了test文件夹里面放了UserEnv.class
cc.jsp放在examples下
用http://localhost:8080/examples/cc.jsp访问
结果正确,输出:this is cc.jsp:aaa
我还曾修改server.xml
在之后,之前加如
并且用http://localhost:8080/oa/cao.jsp访问E:jspweboa下的cao.jsp也能显示正确结果
于是
我在E:jspweboa下面建了WEB-INFclassestest等文件夹test里面放了刚才UserEnv.class文件
同时把cc.jsp考到E:jspweboa下面
想用http://localhost:8080/oa/cc.jsp 来访问cc.jsp以及UserEnv.class
但是行不通
提示错误如下:
An error occurred at line: 1 in the jsp file: /cc.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:Tomcat 4.1workStandalonelocalhostoacc_jsp.java:42: ??????
???? UserEnv
???? in test
test.UserEnv myenv = null;
^
An error occurred at line: 1 in the jsp file: /cc.jsp
Generated servlet error:
C:Tomcat 4.1workStandalonelocalhostoacc_jsp.java:44: ??????
???? UserEnv
???? in test
myenv = (test.UserEnv) pageContext.getAttribute("myenv", PageContext.SESSION_SCOPE);
^
An error occurred at line: 1 in the jsp file: /cc.jsp
Generated servlet error:
C:Tomcat 4.1workStandalonelocalhostoacc_jsp.java:47: ??????
???? UserEnv
???? in test
myenv = (test.UserEnv) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "test.UserEnv");
^
3 ???
请问这是什么原因?
如何才能才能实现指定目录下的javabean访问?
Untitled
this is cc.jsp:
UserEnv.java内容如下:
package test;
import java.io.*;
public class UserEnv{
private String userdir = "";
private String userurl = "";
public UserEnv(){
userdir="aaa";
System.out.println("init userdir, one time");
}
public void setUserDir(String str)
{
userdir=str;
}
public String getUserdir() throws Exception{
return userdir;
}
}
我编译以后在examples下WEB-INFclasses下建了test文件夹里面放了UserEnv.class
cc.jsp放在examples下
用http://localhost:8080/examples/cc.jsp访问
结果正确,输出:this is cc.jsp:aaa
我还曾修改server.xml
在之后,之前加如
并且用http://localhost:8080/oa/cao.jsp访问E:jspweboa下的cao.jsp也能显示正确结果
于是
我在E:jspweboa下面建了WEB-INFclassestest等文件夹test里面放了刚才UserEnv.class文件
同时把cc.jsp考到E:jspweboa下面
想用http://localhost:8080/oa/cc.jsp 来访问cc.jsp以及UserEnv.class
但是行不通
提示错误如下:
An error occurred at line: 1 in the jsp file: /cc.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:Tomcat 4.1workStandalonelocalhostoacc_jsp.java:42: ??????
???? UserEnv
???? in test
test.UserEnv myenv = null;
^
An error occurred at line: 1 in the jsp file: /cc.jsp
Generated servlet error:
C:Tomcat 4.1workStandalonelocalhostoacc_jsp.java:44: ??????
???? UserEnv
???? in test
myenv = (test.UserEnv) pageContext.getAttribute("myenv", PageContext.SESSION_SCOPE);
^
An error occurred at line: 1 in the jsp file: /cc.jsp
Generated servlet error:
C:Tomcat 4.1workStandalonelocalhostoacc_jsp.java:47: ??????
???? UserEnv
???? in test
myenv = (test.UserEnv) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "test.UserEnv");
^
3 ???
请问这是什么原因?
如何才能才能实现指定目录下的javabean访问?
|
把conf中server中的
webapps改为你的目录就可以了
webapps改为你的目录就可以了
|
在UserEnv的前面加上package test;重新编译就OK了
|
同样的,你要把E:jspweboaWEB-INFclasses路径加入到classpath里去
|
同意 beyond_xiruo(希偌) 的
|
好象是配置的问题,在配置文件里把WEB-INF/classes改成绝对路径试一下.