<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.List,java.util.LinkedList" %>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%!
public class Test {
private String info;
private int age;
private Integer age1;
private double score;
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Integer getAge1() {
return age1;
}
public void setAge1(Integer age1) {
this.age1 = age1;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
}
%>
<%
Test test = new Test();
test.setInfo("haha");
test.setAge(11);
test.setAge1(new Integer(9));
test.setScore(5.6);
Test test1 = new Test();
test1.setInfo("苦苦");
test1.setAge(22);
test1.setAge1(new Integer(15));
test1.setScore(4.9);
List list = new LinkedList();
list.add(test);
list.add(test1);
request.setAttribute("test", test);
request.setAttribute("list", list);
%>
<c:out value="${requestScope.test.info}" default="无"/>
<c:if test="${requestScope.test.age>10}">
年龄大于10
</c:if>
<c:set var="str" value="haha1"></c:set>
<c:choose>
<c:when test="${test.info==str}">
这是hah施氮肥
</c:when>
<c:otherwise>
哈这不是这个年龄.<br/>
</c:otherwise>
</c:choose>
<c:forEach items="${list}" var="test" varStatus="status">
<c:if test="${status.index == 0}">
信息:<c:out value="${test.info}"></c:out><br/>
文本信息:<input type="text" value="<c:out value="${test.info}"/>"/>
</c:if>
</c:forEach>
</body>
</html>