OGNL、JSTL/EL表达式的用法

来源:互联网 发布:windows卡在欢迎界面 编辑:程序博客网 时间:2024/05/17 20:35

这是action

package cn.itcast.action;



import javax.annotation.Resource;


import org.springframework.stereotype.Controller;


import com.opensymphony.xwork2.ActionContext;


import cn.itcast.service.EmployeeService;


@Controller //employeeAction
public class EmployeeAction {
@Resource EmployeeService employeeService;

public String execute(){
ActionContext.getContext().put("employee", employeeService.list()); 

return "list";
}


}


这是jsp页面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>员工列表</title>
</head>
<body>
    GONL:
    <br/>
    <s:iterator value="#request.employee">
    <s:property value="username"/> ,<s:property value="password"/> ,<s:property value="gender"/><br/>
    </s:iterator>
    <br/>
    <a href="<s:url action="manage_addUI" namespace="/employee" />">员工添加</a>
    <br>
    JSTL/EL:
    <br/>
    <c:forEach items="${employee}" var="employees">
    ${employees.username},${employees.password},${employees.gender} <br/>
    
    
    </c:forEach>


</body>
</html>





原创粉丝点击