【发布时间】:2015-11-30 23:05:33
【问题描述】:
我在 Eclipse Java EE IDE(Luna Release 2 (4.4.2) 和 Java jre1.8.0_66)中创建了一个 Java 类。
package com.luv2code.jsf.hello;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class Student {
private String sfirstName;
private String slastName;
// create a no-arg constructor
public Student() {
}
public String getFirstName() {
return sfirstName;
}
public void setFirstName(String sfirstName) {
this.sfirstName = sfirstName;
}
public String getLastName() {
return slastName;
}
public void setLastName(String slastName) {
this.slastName = slastName;
}
// define public getter and setter methods to expose properties of the managed Bean
}
我得到的错误是:
HTTP Status 500- Unresolved compilation problems
type Exception report
message unresolved compilation problem
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Unresolved compilation problems:
The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
String cannot be resolved to a type
String cannot be resolved to a type
Implicit super constructor Object() is undefined. Must explicitly invoke another constructor
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.Error: Unresolved compilation problems:
The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
String cannot be resolved to a type
String cannot be resolved to a type
Implicit super constructor Object() is undefined. Must explicitly invoke another constructor
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
com.luv2code.jsf.hello.Student.<init>(Student.java:1)r
com.luv2code.jsf.hello.Student.<init>(Student.java:1)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186)
com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:100)
com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:80)
org.apache.el.parser.AstValue.getValue(AstValue.java:137)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
javax.faces.component.UIOutput.getValue(UIOutput.java:174)
javax.faces.component.UIInput.getValue(UIInput.java:291)
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
如果我将鼠标悬停在字符串上,我会看到
字符串无法解析为类型
如果我将鼠标悬停在 Student(无参数构造函数)上,我会看到:
隐式构造函数 Object() 未定义。必须显式调用另一个构造函数。
我不确定为什么它不允许我在 m Student 类中使用私有字符串。 谁能解释一下或者给我一些建议?
【问题讨论】:
标签: java eclipse compiler-errors