JSP中使用自定义的java类
我在eclipse的JEE版本中创建了一个java类和jsp//User.java:packagecn.mldn.lxh.dbc;publicclassUser{priv...
我在eclipse的JEE版本中创建了一个java类和jsp
//User.java:
package cn.mldn.lxh.dbc;
public class User {
private String name = "xxxx";
private String password = "1111";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
//test.jsp
<%@ page language="java" contentType="text/html; charset=GBK" %>
<%@ page import="cn.mldn.lxh.dbc.*" %>
<%
User user = new User();
out.println(user.getName());
%>
为什么会提示如下错误:
org.apache.jasper.JasperException:Unable to compile class for JSP:
An error occurred at line: 4 in the jsp file: /test.jsp
User cannot be resolved to a type
直接用import语句不行么?? 展开
//User.java:
package cn.mldn.lxh.dbc;
public class User {
private String name = "xxxx";
private String password = "1111";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
//test.jsp
<%@ page language="java" contentType="text/html; charset=GBK" %>
<%@ page import="cn.mldn.lxh.dbc.*" %>
<%
User user = new User();
out.println(user.getName());
%>
为什么会提示如下错误:
org.apache.jasper.JasperException:Unable to compile class for JSP:
An error occurred at line: 4 in the jsp file: /test.jsp
User cannot be resolved to a type
直接用import语句不行么?? 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询