JSP标准动作

JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 JSP标准动作

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.xzit.erpmodel.users.domain.SysUsers"%>
<!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>UseBean 动作的使用</title>
</head>
<%
    String name = "汤姆森";
%>
    <body>
        <jsp:useBean id="userObj" class="com.xzit.erpmodel.users.domain.SysUsers"
            scope="request"></jsp:useBean>
        
        <jsp:setProperty property="name" name="userObj" value="<%=name %>"/>
        <%-- 
        <jsp:setProperty property="granted" name="userObj" param="granted"/>
        <jsp:setProperty property="roles" name="userObj" param="roles"/>
        --%>
        <jsp:setProperty property="*" name="userObj"/>
        
        <%
            Object obj = pageContext.getAttribute("userObj");
            SysUsers sysuser = null;
            if(obj != null){
                sysuser = (SysUsers)obj;%>
                
                用户名:<%=sysuser.getName()%>
            <%}
        %>
        <%-- 使用getProperty 动作完成获取目标Java Bean 属性值 --%>
        用户名称:<jsp:getProperty property="name" name="userObj"/><br>
        用户密码:<jsp:getProperty property="password" name="userObj"/><br>
        是否授权:<jsp:getProperty property="granted" name="userObj"/><br>
        角色范围:<jsp:getProperty property="roles" name="userObj"/><br>
        <jsp:forward page="usebean2.jsp"></jsp:forward> >
    </body>
</html>
package com.xzit.erpmodel.users.domain;

public class SysUsers {
     private String id;//主键            
     private String name;//登录名称        
     private String password;//密码            
     private double granted;//是否已经被授权使用系统1是0否 
     private String empid;//员工id 外键     
     private java.sql.Timestamp lastTime;//最后登陆系统时间 
     private String roles;//角色范围
     
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        System.out.println("获取name属性的值");
        return name;
    }
    public void setName(String name) {
        System.out.println("设置name属性的值");
        this.name = name;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public double getGranted() {
        return granted;
    }
    public void setGranted(double granted) {
        this.granted = granted;
    }
    public String getEmpid() {
        return empid;
    }
    public void setEmpid(String empid) {
        this.empid = empid;
    }
    public java.sql.Timestamp getLastTime() {
        return lastTime;
    }
    public void setLastTime(java.sql.Timestamp lastTime) {
        this.lastTime = lastTime;
    }
    public String getRoles() {
        return roles;
    }
    public void setRoles(String roles) {
        this.roles = roles;
    }
     
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.xzit.erpmodel.users.domain.SysUsers"%>
<!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>UseBean 动作的使用</title>
</head>
    <body>
    
         <%
            Object obj = request.getAttribute("userObj");
            SysUsers sysuser = null;
            if(obj != null){
                sysuser = (SysUsers)obj;%>
                
                用户名称:<%=sysuser.getName() %><br>
                角色密码:<%=sysuser.getPassword() %><br>
                是否授权:<%=sysuser.getGranted() %><br>
                角色范围:<%=sysuser.getRoles() %><br>
            <%}
        %> 
        ${userObj.name}<br>
        ${userObj.password}<br>
        ${userObj.granted}<br>
        ${userObj.roles}<br>
        
    </body>
</html>

 

上一篇:Java数据结构---线索二叉树递归创建与遍历


下一篇:信息学算法竞赛C++缺省源 模板