日期:2014-05-16  浏览次数:20425 次

struts2开发中在jsp页面中用js取得action中传过来的值
使用struts2开发中,在jsp页面的js中用EL表达式取得action中传过来的值。
Action代码如下:
public class FrameLayoutAction extends BaseAction{
    private static final long serialVersionUID = -2065227327273288067L;
	
    private String loginUserName;
    private String employeeSN;

    public string login(){
        loginUserName = "wangruiling";
        employeeSN="20003101";
    }

    public String getEmployeeSN() {
        return employeeSN;
    }

    public void setEmployeeSN(String employeeSN) {
	this.employeeSN = employeeSN;
    }

    public String getLoginUserName() {
	return loginUserName;
    }

    public void setLoginUserName(String loginUserName) {
	this.loginUserName = loginUserName;
    }
}


在jsp中的js中获得employeeSN和loginUserName的值,实现代码如下:
<%@ page language="java" contentType="text/html;charset=UTF-8" isELIgnored="false"
	import="java.util.HashMap" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>链家地产销售交易管理系统</title>
<script type="text/javascript" src="scripts/jquery-1.4.2/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="scripts/EimUtil.js"></script>
<%@ include file="/common/colorbox.jsp"%>
<script type="text/javascript">
$(document).ready(function(){
	//集成IM
	var employeeSN = "${employeeSN}";
	EimUtil.RunEim(employeeSN);
});

</script>
</head>
<body class="easyui-layout">
    <div class="loginbar">
      <div class="loginBox">
        <div class="loginName">${loginUserName}</div>
      </div>
    </div>
</body>
</html>