JSTL1.1 <c:set target="Bean"...>的问题
JavaBean
package jstlex;
public class Bean1 {
private String name;
private String age;
public Bean1() {
}
public void setName(String name) {
this.name = name;
}
public void setAge(String age) {
this.age = age;
}
public String getName() {
return name;
}
public String getAge() {
return age;
}
}
JSP
<%@ page contentType= "text/html; charset=GBK " %>
<%@ taglib uri= "http://java.sun.com/jsp/jstl/core " prefix= "c " %>
<jsp:useBean id= "userBean " scope= "session " class= "jstlex.Bean1 "/>
<html>
<head>
<title>
jsp1
</title>
</head>
<body bgcolor= "#ffffff ">
<c:set var= "name " target= "userBean " property= "name " value= "Lou "/>
<c:out value= "${name} "/> <br /> <!--可以输出Lou-->
<%=userBean.getName()%> <!--输出null-->
</body>
</html>
------解决方案-------------------- <%@ page contentType= "text/html; charset=GBK " %>
<%@ taglib uri= "http://java.sun.com/jstl/core_rt " prefix= "c " %>
<%
String[] names={ "xu 23 ", "lou 23 "};
pageContext.setAttribute( "names ",names);
%>
<c:forEach var= "name " items= "${names} "> ${name} <br>
</c:forEach>