相关疑难解决方法(0)

识别并解决javax.el.PropertyNotFoundException:Target Unreachable

当尝试在EL中引用托管bean时#{bean.entity.property},有时会javax.el.PropertyNotFoundException: Target Unreachable抛出异常,通常是在设置bean属性时,或者要调用bean操作时.

似乎有五种不同的消息:

  1. 目标无法访问,标识符'bean'已解析为null
  2. 目标无法访问,'entity'返回null
  3. 目标无法访问,'null'返回null
  4. 目标无法访问,''0'返回null
  5. 目标无法访问,'BracketSuffix'返回null

这些都意味着什么?它们是如何引起的,它们应该如何解决?

jsf el cdi managed-bean propertynotfoundexception

117
推荐指数
2
解决办法
11万
查看次数

使用JSTL <c:forEach>标记迭代List和Map的元素

如果我有一个JSF支持bean返回一个ArrayList类型的对象,我应该可以<c:foreach>用来迭代列表中的元素.每个元素都包含一个地图,虽然这里已经回答了如何通过JSTL访问地图内容的问题,如果我传递了这样的地图数组,我找不到如何迭代它们仍然使用JSTL访问地图内容.有文档引用简单的迭代器,但不是那些项目本身就是映射的文档.

如果有人能给我一个简单的例子来说明如何在JSP中迭代java List我会非常感激.标记

foreach jsp jstl list hashmap

51
推荐指数
1
解决办法
22万
查看次数

javax.el.PropertyNotFoundException:属性'foo'在类型java.lang.Boolean上不可读

我有一个看起来像这样的类:

public class ScoreDefinition {

    protected Boolean primary;

    public Boolean isPrimary() {
        return primary;
    }

    public void setPrimary(Boolean value) {
        this.primary = value;
    }

}
Run Code Online (Sandbox Code Playgroud)

我试图primary在EL中访问它的属性,如下所示:

<c:forEach var="score" items="${scores}">
    <input type="checkbox"
           value="${score.primary}"
           name="someName"
           class="textField"/>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)

但我得到了例外:

javax.el.PropertyNotFoundException: Property 'primary' not readable on type java.lang.Boolean
    at javax.el.BeanELResolver$BeanProperty.read(BeanELResolver.java:280)
    at javax.el.BeanELResolver$BeanProperty.access$000(BeanELResolver.java:230)
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:81)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:123)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
    at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:938)
    at org.apache.jsp.WEB_002dINF.views.administer.projectBlocks_jsp._jspx_meth_c_005fforEach_005f2(projectBlocks_jsp.java:806)
    at org.apache.jsp.WEB_002dINF.views.administer.projectBlocks_jsp._jspx_meth_c_005fif_005f2(projectBlocks_jsp.java:709)
    at org.apache.jsp.WEB_002dINF.views.administer.projectBlocks_jsp._jspx_meth_form_005fform_005f0(projectBlocks_jsp.java:245)
    at org.apache.jsp.WEB_002dINF.views.administer.projectBlocks_jsp._jspService(projectBlocks_jsp.java:150)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) …
Run Code Online (Sandbox Code Playgroud)

jsp boolean el propertynotfoundexception

26
推荐指数
2
解决办法
2万
查看次数

Java表达式语言如何解析布尔属性?(在JSF 1.2中)

所以我们都知道#{someBean.value}会尝试获取someBean被调用的某些属性的内容value.它会寻找getValue().但是,如果这个属性是boolean什么?它会寻找isValue().它不会寻找的是hasValue().

这让我思考,究竟是做什么的?

Java EE 5教程章节 - 统一表达式语言是指PageContext.FindAttribute().PageContext送你去JSPContext.他们都没有真正解释他们遵循的规则来确定他们正在寻找的方法的名称.

找到说方法名称必须以get开头的文档也相当容易.但是,我知道这很isValue()有效.

任何人都可以指向我写下来的文档.我不是在寻找我正在寻找参考的教程或示例.

jsf jsp boolean el

13
推荐指数
2
解决办法
9567
查看次数

尝试解析EL中的布尔属性时出现javax.el.PropertyNotFoundException

我有以下树节点类:

public abstract class DocumentTreeNode extends TreeNodeImpl implements javax.swing.tree.TreeNode
{
    private Boolean isToC;

    ...

    public Boolean isToC()
    {
        return isToC;
    }

    public void setToC(Boolean isToC)
    {
        this.isToC = isToC;
    }

}
Run Code Online (Sandbox Code Playgroud)

这是一个简单的复选框,指示文档是否包含在任何内容中.但是,当试图从JSF 2 EL中引用它时

...
<h:selectBooleanCheckbox value="#{node.isToC}" />
...
Run Code Online (Sandbox Code Playgroud)

我得到一个例外:

引起:javax.el.PropertyNotFoundException:/main.xhtml @ 541,64 value ="#{node.isToC}":类'ChapterTreeNode'没有属性'isToC'.

(我想我几乎尝试了所有组合,至少我觉得这样...... ;-))

如何解决该布尔属性?需要改变什么?

jsf boolean el naming-conventions propertynotfoundexception

13
推荐指数
1
解决办法
2万
查看次数

javax.el.PropertyNotFoundException:在JSP中使用JSTL

我有一个JSP,我正在尝试使用JSTL标记来显示类的内存实例中的数据.数据由一系列字符串组成,其中每个字符串是RSS提要的地址.

在JSP中,我有以下代码:

<table border = "1">
    <tr>
        <c:forEach var = "rssFeedURL" items = "${rssfom.rssFeedURLs}">
            <td align = "left">${rssFeedURL}</td>
        </c:forEach>
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

基本上,rssfom是以下类的实例:

public class RSSFeedOccurrenceMiner extends RSSFeedMiner {

   private HashMap<String, Counter> keywordFrequencies;

   public RSS_Feed_OccurrenceMiner() {
      super();
      this.keywordFrequencies = new HashMap();
   }
   ...
}
Run Code Online (Sandbox Code Playgroud)

这继承自RSSFeedMiner类,它包含以下变量和方法:

private ArrayList<String> rssFeedURLs;

public ArrayList<String> getRSSFeedURLs() {
    return rssFeedURLs;
}

public void setRSSFeedURLs(ArrayList<String> rssFeedURLs) {
    this.rssFeedURLs = rssFeedURLs;
}
Run Code Online (Sandbox Code Playgroud)

所以在JSP中,我以为我可以使用上面的代码但是当页面运行时,我只是收到一个空表.在服务器日志中,我倾向于找到消息:

javax.el.PropertyNotFoundException:在类型RSSFeedOccurrenceMiner上找不到属性'rssFeedURLs'

鉴于我对继承的使用,这是正确的.那么有人能告诉我JSTL是否允许继承或者我的代码中是否缺少某些内容?

我真的不想在JSP中使用scriptlet.

jsp jstl el propertynotfoundexception

10
推荐指数
2
解决办法
2万
查看次数

Outcommented Facelets代码仍调用#{bean.action()}之类的EL表达式,并在#{bean.action}上导致javax.el.PropertyNotFoundException

我的Facelet中有以下代码片段:

<h:commandLink id="cmdbtn">
    <f:ajax event="click" execute="@form"
            listener="#{screenShotBean.takeScreenshot}" />
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)

它工作正常,但当我像这样取消它,

<!--        <h:commandLink id="cmdbtn"> -->
<!--            <f:ajax event="click" execute="@form" -->
<!--                    listener="#{screenShotBean.takeScreenshot}" /> -->
<!--        </h:commandLink> -->
Run Code Online (Sandbox Code Playgroud)

然后它抛出以下异常:

javax.el.PropertyNotFoundException: Property 'takeScreenshot' not found on type monstage.test.com.ScreenShotBean
    at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237)
    at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214)
    at javax.el.BeanELResolver.property(BeanELResolver.java:325)
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
    at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217)
    at com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:157)
    at com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:77)
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
    at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at …
Run Code Online (Sandbox Code Playgroud)

jsf comments facelets el propertynotfoundexception

7
推荐指数
1
解决办法
3391
查看次数

javax.el.PropertyNotFoundException:在类型上找不到属性"名称"

我有一个代码如下:

FriendsList = new ArrayList()
....   
ResultSet rs = st.executeQuery(Select);
while (rs.next()) {
   Member member = new Member(rs);
   FriendsList.add(member);
}
Run Code Online (Sandbox Code Playgroud)

它成功获取结果并转到Member类的构造函数并向其添加数据.但是一旦我尝试使用我的jsp文件中的FriendsList属性访问其中一个属性,我遇到以下错误:

 "Caused by: javax.el.PropertyNotFoundException: Property 'Name' not found on type   
 application.Member"
Run Code Online (Sandbox Code Playgroud)

使用Eclipse我已经为Member类的每个属性生成了一个完整的setter和getter列表,如下所示:

    public String getName() {
    return Name;
}
public void setName(String name) {
    Name = name;
}
Run Code Online (Sandbox Code Playgroud)

jsp struts2

5
推荐指数
1
解决办法
2万
查看次数

javax.el.PropertyNotFoundException:类'xxx'没有可读属性'yyy'

我在下面的会话作用域CDI托管bean:

@Named
@SessionScoped
public class RegisterController implements Serializable {   
    private static final long serialVersionUID = 1L;

    @Inject
    private MitgliedAbc mitgliedAbc;

    public MitgliedAbc getMitgliedABC() {
        return mitgliedAbc;
    }

    public void setMitgliedAbc (MitgliedAbc mitgliedAbc) {
        this.mitgliedAbc = mitgliedAbc;
    }

}
Run Code Online (Sandbox Code Playgroud)

并以JSF形式输入以下内容:

<h:inputText value="#{registerController.mitgliedAbc.mgEmail}" />
Run Code Online (Sandbox Code Playgroud)

部署到GlassFish 4.1并在浏览器中打开页面时,会引发以下异常:

javax.el.PropertyNotFoundException:/register.xhtml @ 27,66 value ="#{registerController.mitgliedAbc.mgEmail}":类'com.example.RegisterController'没有可读属性'mitgliedAbc'.

这是怎么造成的,我该如何解决?

jsf el managed-bean

4
推荐指数
1
解决办法
1万
查看次数

JSTL没有在JavaBean中找到属性

我有一个问题非常类似于这个堆栈溢出问题JSP没有在bean中查找属性.还有这个问题javax.el.PropertyNotFoundException:在类型com.example.Bean上找不到属性'foo'.然而在我的情况下,我认为我已经完成了所有的书籍,我仍然得到一个错误. 下面是我的javabean代码片段的一部分

    private double otheramount;
    private int no;
    private String name;


        public double getOtherAmount()
            {
                return otheramount;
            }
            public void setOtherAmount(double newotheramount)
            {
                otheramount = newotheramount;        
            }
public int getNo()
            {
                return no;
            }
            public void setNo(int newno)
            {
                no = newno;        
            }
public String getName()
            {
                return name;
            }
            public void setName(String newname)
            {
                name = newname;        
            }
Run Code Online (Sandbox Code Playgroud)

以下是我的DAO代码的一部分

while(rs.next())
         {

              MyBean mybean = new MyBean();

              mybean.setNo(rs.getInt("No"));
              mybean.setName(rs.getString("Full_Names"));              
              mybean.setOtherAmount(rs.getDouble("OtherAmount"));              

              allresults.add(mybean);



         }
Run Code Online (Sandbox Code Playgroud)

下面是servlet代码的一部分

try
{
ArrayList …
Run Code Online (Sandbox Code Playgroud)

java jsp jstl exception

2
推荐指数
1
解决办法
1826
查看次数

JSP页面中的PropertyNotFoundException

我有一个Java bean类如下

public class Users extends dbConnect
{
   private int UserId;  

   public int getUserId() 
   {
    return UserId;
   }

   public void setUserId(int userId) 
   {
     UserId = userId;
   }
}
Run Code Online (Sandbox Code Playgroud)

我在我的Servlet中有一个doGet方法,它获取javabean类中的值并在JSP页面中显示.ListUsers方法将从数据库返回一个列表.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {
        List<Users> arrUserList = new ArrayList<Users>();

        Users objUser = new Users();
        arrUserList   = objUser.listUsers();

        for(Users Userobj : arrUserList)
        {
            System.out.println(Userobj.getUserId());
        }

        request.setAttribute("arrUserDetails", arrUserList);

        RequestDispatcher rst = request.getRequestDispatcher("ListUsers.jsp");
        rst.forward(request, response);
    }
Run Code Online (Sandbox Code Playgroud)

当我在for循环上面打印UserId的值时,显示UserId.But它没有显示在我的JSP页面中.

<%@ page  import="com.acme.users.Users"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:forEach items="${arrUserDetails}" var="account">
<tr> …
Run Code Online (Sandbox Code Playgroud)

jsp el propertynotfoundexception

1
推荐指数
1
解决办法
2万
查看次数