【问题标题】:Cannot find any information on property in bean... in Hello World在 Hello World 中找不到任何关于 bean 中的属性的信息...
【发布时间】:2013-07-03 20:34:40
【问题描述】:

我刚开始在 Adob​​e CQ 中使用 JSP,我正在尝试做一个简单的 Hello World 来访问世界上最简单的 Bean 中的数据。从我读过的所有内容来看,这是正确的。这是怎么回事?

我的 JSP (html.jsp) 是:

<%@page session="false"
        contentType="text/html;charset=UTF-8"
        import="org.apache.sling.api.request.ResponseUtil"
%>
<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
<sling:defineObjects/>
<html>
  <body>
<jsp:useBean id="myBean" class="com.example.helloBean.SampleUtil" >
        <jsp:getProperty name="myBean" property="text"/>
      </jsp:useBean>
  </body>
</html>

我修改了模板生成的“Hello World”类(SampleUtil.java)如下:

package com.example.helloBean;
public class SampleUtil{
    private String text;
    public SampleUtil(){
        this.text = "Hello World.";
    }
    public  String getText() {
        return text;
    }
    public void setText(String text){
    this.text = text;
    }
}

当访问我得到的页面时

Cannot find any information on property 'text' in a bean of type 'com.example.helloBean.SampleUtil'

可能的相关细节: 我在 CQ 中使用 /apps 上的 CRXDELite 中的“创建项目”命令生成了这个,它创建了一个工作的 Hello World,然后修改了上面的两个文件。

【问题讨论】:

    标签: jsp javabeans jsp-tags aem


    【解决方案1】:

    尝试将包名称helloBean 重命名为hellobean。它应该只包含小写字母。

    【讨论】:

      【解决方案2】:

      我也遇到了同样的问题。只需将所有方法的名称更改为小写字母

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-04-10
        • 1970-01-01
        • 2017-09-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-05
        • 1970-01-01
        相关资源
        最近更新 更多