<c:set>标签设置javabean属性时出现的问题
提示的错误如下:
org.apache.jasper.JasperException: Invalid property in <set>: "age"
org.apache.jasper.servlet.JspServletWrapper.handle
JspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
代码如下:
package ch09;
public class TestBean {
private int age;
public void setAge(int age)
{
this.age = age;
}
public int getAge()
{
return age;
}
}
<%@ page contentType="text/html;charset=gb2312"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:useBean id="test" scope="session" class="ch09.TestBean"/>
<html>
<body>
<center>
<c:set value="25" target="test" property="age"/>
<c:out value="${test.age}"/>
</center>
</body>
</html>
------解决方案--------------------
<c:set value="25" target="test" property="age"/>
请改为 <c:set value="25" target=${test} property="age"/>