IT_newbies
IT_newbies
采纳率52.9%
2016-02-13 03:24 阅读 1.5k

Javaee EL访问javabean属性出错 就两行代码也会出错我都无语了

/jsp:useBean
${b.id}
.................................................................................................下面是Bean那个类
public class Bean {
String id;
String name;
public Bean() {
id="1";
name="2";
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}

}
.................................................................................................下面是错误提示
type Exception report

message Unable to compile class for JSP:

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: 12 in the jsp file: /index.jsp
Bean cannot be resolved to a type
9:

Insert title here
10:
11:
12: /jsp:useBean
13: ${b.id}
14:

15:

An error occurred at line: 12 in the jsp file: /index.jsp
Bean cannot be resolved to a type
9:

Insert title here
10:
11:
12: /jsp:useBean
13: ${b.id}
14:

15:

An error occurred at line: 12 in the jsp file: /index.jsp
Bean cannot be resolved to a type
9:

Insert title here
10:
11:
12: /jsp:useBean
13: ${b.id}
14:

15:

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.30 logs.


Apache Tomcat/8.0.30

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • fk002008 lambda-fk 2016-02-13 05:40

    Bean cannot be resolved to a type

    你使用的时候这个bean定义了没

    或者

    点赞 评论 复制链接分享
  • fk002008 lambda-fk 2016-02-13 05:42
    <bean:define id='b' type='xxx.Bean'>
    或者
    <jsp:useBean id="b" scope="page" class="xxx.Bean"/>
    
    
    点赞 评论 复制链接分享
  • qwe885167759 岑如花 2016-02-13 10:29

    构造函数不要加Public

    点赞 评论 复制链接分享
  • qq_20039385 qq_20039385 2016-02-15 03:15

    属性默认的修饰符是protected在外部是不能访问的,在属性前加上public关键字来修饰就可以啦。
    public String id;
    public String name;

    点赞 评论 复制链接分享

相关推荐