我编写了一个使用 Bean 类的简单 jsp 代码 - BeanDemo。 我正在使用 NetBeans IDE 和 GlassFish Server 4.0。 现在,当我尝试运行 jsp 文件时,出现上述异常。 我在 StackOverflow 中寻找类似的问题,但似乎没有一个答案能解决我的问题。或者我可能错过了什么。我是新来的,所以请善待:) 谢谢!
1.beaneg.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<jsp:useBean id="demo" class="beanpack.BeanDemo">
<OL>
<LI>
<I> ${demo.str} </I>
<LI> <jsp:setProperty name="demo" property="str"
value="This is New Message" />
<I> <jsp:getProperty name="demo" property="str" /> </I>
</OL>
</jsp:useBean>
</body>
</html>
BeanDemo.java
package beanpack;
public class BeanDemo {
private String str="Hello";
public BeanDemo()
{
}
public String getMessage()
{
return str;
}
public void setMessage( String str)
{
this.str=str;
}
}
最佳答案
您需要将属性名称指定为 message
而不是 str
。
<jsp:getProperty name="demo" property="message" >
关于java - 组织.apache.jasper.JasperException : PWC6054: Cannot find any information on property 'str' in a bean of type 'beanpack.BeanDemo' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31614469/