部门模块删除

  1. DepartmentService

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    package cn.itcast.shoa.service;

    import java.io.Serializable;
    import java.util.Collection;

    import cn.itcast.shoa.domain.system.Department;

    public interface DepartmentService{
    //Collection集合的最顶级接口
    public Collection<Department> getAllDepartments();

    public void saveDepartment(Department department);
    //删除部门方法
    public void deleteDepartment(Long id);
    //获取部门id方法
    public Department getDepartmentById(Serializable id);

    }
  2. DepartmentServiceImpl

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    package cn.itcast.shoa.service.impl;

    import java.io.Serializable;
    import java.util.Collection;

    import javax.annotation.Resource;

    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    import cn.itcast.shoa.dao.DepartmentDao;
    import cn.itcast.shoa.domain.system.Department;
    import cn.itcast.shoa.service.DepartmentService;

    @Service("departmentService")
    public class DepartmentServiceImpl implements DepartmentService{
    @Resource(name = "departmentDao")
    private DepartmentDao departmentDao;

    @Override
    public Collection<Department> getAllDepartments() {
    // TODO Auto-generated method stub
    return this.departmentDao.getAllEntry();
    }

    @Transactional(readOnly=false)
    public void saveDepartment(Department department) {
    this.departmentDao.saveEntry(department);
    }

    @Transactional(readOnly=false)
    public void deleteDepartment(Long id) {
    // TODO Auto-generated method stub
    this.departmentDao.deleteEntry(id);
    }

    @Override
    public Department getDepartmentById(Serializable id) {
    // TODO Auto-generated method stub
    return this.departmentDao.getEntryById(id);
    }
    }
  3. DepartmentAction

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    package cn.itcast.shoa.struts.action;

    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import java.util.Set;

    import javax.annotation.Resource;

    import org.springframework.beans.BeanUtils;
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Controller;

    import com.opensymphony.xwork2.ActionContext;

    import cn.itcast.shoa.domain.system.Department;
    import cn.itcast.shoa.domain.system.User;
    import cn.itcast.shoa.service.DepartmentService;
    import cn.itcast.shoa.struts.action.base.BaseAction;

    @Controller("departmentAction")
    @Scope("prototype")
    public class DepartmentAction extends BaseAction<Department>{
    @Resource(name="departmentService")
    private DepartmentService departmentService;

    //方法名最好不以get开头
    public String showAllDepartment() {
    //list集合必须放入值栈中才能用ognl表达式获取数据 两种做法:对象栈与map栈
    Collection<Department> departmentsList = this.departmentService.getAllDepartments();
    //放入map
    ActionContext.getContext().put("departmentList", departmentsList);
    return listAction;
    }

    //测试map中迭代的元素在栈顶
    public String showList() {
    Department department = new Department();
    department .setName("华沙");
    List<Department> dList = new ArrayList<Department>();
    dList.add(department);
    ActionContext.getContext().put("dlist", dList);
    return listAction;
    }

    public String showMap() {
    Department department = new Department();
    department .setName("华沙");
    Map<String, Department> map = new HashMap<String, Department>();
    map.put("m1", department);
    ActionContext.getContext().put("map", map);
    return listAction;
    }

    public String showListMap() {
    List<Map<String, Department>> list = new ArrayList<Map<String,Department>>();
    Map<String, Department> map = new HashMap<String, Department>();
    Department department = new Department();
    department.setName("沙耶香");
    map.put("M1", department);
    list.add(map);
    ActionContext.getContext().put("listMap", list);
    return listAction;
    }

    public String showMapList() {
    Map<String, List<Department>> map = new HashMap<String, List<Department>>();
    List<Department> list = new ArrayList<Department>();
    Department department = new Department();
    department.setName("宫水三叶");
    list.add(department);
    map.put("list1", list);
    ActionContext.getContext().put("maplist", map);
    return listAction;
    }

    public String showListMapList() {
    List<Map<String, List<Department>>> list = new ArrayList<Map<String,List<Department>>>();

    Department department = new Department();
    department.setName("立花泷");
    List<Department> dList = new ArrayList<Department>();
    dList.add(department);

    Map<String, List<Department>> map = new HashMap<String, List<Department>>();
    map.put("map1", dList);
    list.add(map);
    ActionContext.getContext().put("listMapList", list);
    return listAction;
    }

    public String addUI() {
    return addUI;
    }

    public String add() {
    Department department = new Department();
    /*
    * 把model的值赋值给department
    */
    BeanUtils.copyProperties(this.getModel(), department);
    this.departmentService.saveDepartment(department);
    return action2action;
    }
    /**
    * 1. 提取department对象
    * 2. 获取该部门的所有的用户
    * @return
    */
    public String deleteDepartment() {
    Department department = this.departmentService.getDepartmentById(this.getModel().getDid());
    //提取该部门的用户
    Set<User> users = department.getUsers();
    for(User user:users){
    user.setDepartment(null);//解除user和department之间的关系
    }
    this.departmentService.deleteDepartment(this.getModel().getDid());
    return action2action;
    }
    }
  4. list.jsp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/jsp/common/common.jsp" %>
    <html>
    <head>
    <title>部门列表</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>

    <div id="Title_bar">
    <div id="Title_bar_Head">
    <div id="Title_Head"></div>
    <div id="Title"><!--页面标题-->
    <img border="0" width="13" height="13" src="${pageContext.request.contextPath}/css/images/title_arrow.gif"/> 部门管理
    </div>
    <div id="Title_End"></div>
    </div>
    </div>

    <div id="MainArea">
    <table cellspacing="0" cellpadding="0" class="TableStyle">

    <!-- 表头-->
    <thead>
    <tr align=center valign=middle id=TableTitle>
    <td width="150px">部门名称</td>
    <td width="200px">职能说明</td>
    <td>相关操作</td>
    </tr>
    </thead>

    <!--显示数据列表-->
    <tbody id="TableData" class="dataContainer" datakey="departmentList">
    <s:iterator value="#departmentList">
    <tr class="TableDetail1 template">
    <td><s:property value="name"/></td>
    <td><s:property value="description"/></td>
    <td>
    <s:a action="departmentAction_deleteDepartment.action?did=%{did}">删除</s:a>
    <a href="saveUI.html">修改</a>
    </td>
    </tr>
    </s:iterator>

    <s:iterator value="#dlist">
    <s:debug></s:debug>
    <s:property value="name"/>
    </s:iterator>

    <!--
    Map<String,Department>
    map中含有Strign,Department
    -->
    <s:iterator value="#map">
    <s:property value="key"/>
    <s:property value="value.name"/>
    </s:iterator>
    <!--
    List<Map<String,Department>>
    -->
    <s:iterator value="#listMap">
    <!--
    list集合中当前迭代的元素在栈顶,所以map在栈顶,如果s:iterator中的value属性不写,默认迭代栈顶的元素
    map的key为M1 这里可不写
    -->
    <s:iterator>
    <s:property value="key"/>
    <s:property value="value.name"/>
    </s:iterator>
    </s:iterator>
    <!--
    Map<String,List<Department>>
    -->
    <s:iterator value="#maplist">
    <s:property value="key"/>
    <s:iterator value="value">
    <s:property value="name"/>
    </s:iterator>
    </s:iterator>
    <!--
    List<Map<String,List<Department>>>
    -->
    <s:iterator value="#listMapList">
    <s:iterator>
    <s:property value="key"/>
    <s:iterator value="value">
    <s:property value="name"/>
    </s:iterator>
    </s:iterator>
    </s:iterator>
    </tbody>
    </table>

    <!-- 其他功能超链接 -->
    <div id="TableTail">
    <div id="TableTail_inside">
    <a href="departmentAction_addUI.action"><img src="${pageContext.request.contextPath}/css/images/createNew.png" /></a>
    </div>
    </div>
    </div>

    <!--说明-->
    <div id="Description">
    说明:<br />
    1,列表页面只显示一层的(同级的)部门数据,默认显示最顶级的部门列表。<br />
    2,点击部门名称,可以查看此部门相应的下级部门列表。<br />
    3,删除部门时,同时删除此部门的所有下级部门。
    </div>

    </body>
    </html>

部门模块修改

  1. DepartmentAction

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    public String updateUI() {
    //数据回显
    Department department = this.departmentService.getDepartmentById(this.getModel().getDid());
    //放入栈顶
    ActionContext.getContext().getValueStack().push(department);
    return UPDATE_UI;
    }

    public String update() {
    Department department = this.departmentService.getDepartmentById(this.getModel().getDid());
    BeanUtils.copyProperties(this.getModel(), department);
    this.departmentService.updateDepartment(department);
    return action2action;
    }
  2. DepartmentService

    1
    public void updateDepartment(Department department);
  3. DepartmentServiceImpl

    1
    2
    3
    4
    5
    @Transactional(readOnly=false)
    public void updateDepartment(Department department) {
    // TODO Auto-generated method stub
    this.departmentDao.updateEntry(department);
    }
  4. struts-department.xml

    1
    <result name="updateUI">/WEB-INF/jsp/system/department/update.jsp</result>
  5. update.jsp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/jsp/common/common.jsp" %>
    <html>
    <head>
    <title>部门设置</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>

    <!-- 标题显示 -->
    <div id="Title_bar">
    <div id="Title_bar_Head">
    <div id="Title_Head"></div>
    <div id="Title"><!--页面标题-->
    <img border="0" width="13" height="13" src="${pageContext.request.contextPath}/css/images/title_arrow.gif"/> 部门信息
    </div>
    <div id="Title_End"></div>
    </div>
    </div>

    <!--显示表单内容-->
    <div id=MainArea>
    <s:form action="departmentAction_update.action">
    <s:hidden name="did"></s:hidden>
    <div class="ItemBlock_Title1"><!-- 信息说明<DIV CLASS="ItemBlock_Title1">
    <IMG BORDER="0" WIDTH="4" HEIGHT="7" SRC="${pageContext.request.contextPath}/css/blue/images/item_point.gif" /> 部门信息 </DIV> -->
    </div>

    <!-- 表单内容显示 -->
    <div class="ItemBlockBorder">
    <div class="ItemBlock">
    <table cellpadding="0" cellspacing="0" class="mainForm">
    <tr><td>部门名称</td>
    <td><s:textfield name="name" cssClass="InputStyle"></s:textfield></td>
    </tr>
    <tr><td>职能说明</td>
    <td><s:textarea name="description" cssClass="TextareaStyle"></s:textarea></td>
    </tr>
    </table>
    </div>
    </div>

    <!-- 表单操作 -->
    <div id="InputDetailBar">
    <input type="image" src="${pageContext.request.contextPath}/css/images/save.png"/>
    <a href="javascript:history.go(-1);"><img src="${pageContext.request.contextPath}/css/images/goBack.png"/></a>
    </div>
    </s:form>
    </div>

    <div class="Description">
    说明:<br />
    1,上级部门的列表是有层次结构的(树形)。<br/>
    2,如果是修改:上级部门列表中不能显示当前修改的部门及其子孙部门。因为不能选择自已或自已的子部门作为上级部门。<br />
    </div>

    </body>
    </html>

  6. list.jsp

    1
    2
    <s:a action="departmentAction_deleteDepartment.action?did=%{did}">删除</s:a>
    <s:a action="departmentAction_updateUI.action?did=%{did}">修改</s:a>

注意事项

  1. 在列表页面中:

    ​ <s:a action=”departmentAction_deleteDepartment.action?did=”>< /s:a>

    ​ 说明:

    1. struts2的标签只能跟ognl表达式

    2. html标签只能跟el表达式

    3. 在struts2的标签中:

      1. s:property中的value属性

      2. s:iterator中的value属性

      3. s:select中的value属性

        以上这些属性都直接能跟ognl表达式寻找相应的数据

      4. s:textfield,s:a中的action等都不能直接跟ognl表达式

        ​ <s:textfield name=”aa” value=”aa” />

        ​ 上述的标签的值为”aa”

        ​ <s:textfield name=”aa” value=”%{aa}” />

        ​ 上述标签中的值为对象栈中key值为aa对应的value属性的值

  2. 在部门模块中,部门和用户是有关联的

    如果在用户表中有一个外键值正好是要删除的部门的主键值,这个时候,删除部门就会报错:主外键的约束

    hibernate在数据库的外键方面的处理:

    1. 外键的维护

      一对多

      ​ 对象与集合的关系

      多对多

      ​ 对象与集合的关系

      多对一

      ​ 对象与对象的关系

  3. 回显

    把一个对象放入对象栈或map栈中都可以进行回显

    放在对象栈中的属性可以利用struts2标签中的name属性进行回显

    放在map栈中的属性可以利用struts2标签中的value属性进行回显

struts2中两个很重要的拦截器

在struts2中获取页面上表单数据有两种方案

  1. 利用属性驱动获取表单中的数据
  2. 利用模型驱动获取表单中的数据

原理

  1. struts2内部有两个拦截器

    在没有任何配置拦截器的情况下,struts2执行默认的拦截器栈defaultStack

    defaultStack中

    • params

      1
      <interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
    • ModelDrivenInterceptor

  2. 在action中

    1
    2
    3
    4
    Department department = this.departmentService.getDepartmentById(this.getModel().getDid());
    //放入栈顶
    ActionContext.getContext().getValueStack().push(department);
    ActionContext.getContext().getValueStack().setParameter("name", "bb");

    在第二行代码中,把department放入对象栈的栈顶,所以department中的属性可以直接在对象栈中进行访问

    利用第三行代码访问了department的name属性,并将name的属性值改为”bb”

  3. 属性驱动的原理

    1. 当前访问的action在对象栈中,所以action中的属性就为对象栈中的key值

    2. 页面表单的name属性的值要与action中属性的名称保持一致

      在parameterInterceptor中

      1
      2
      3
      4
      5
      6
      7
      //把页面上表单的元素的key,value封装成一个map
      Map<String,Object> parameters = retrieveParameters(ac);
      //从map中把key和value值提取出来
      String name = entry.getKey();
      Object value = entry.getValue();
      //给对象栈中的key值赋值相应的value的值
      newStack.setParameter(naem,value);
  4. 模型驱动-ModelDrivenInterceptor

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Object action = invocation.getAction();

    if (action instanceof ModelDriven) {
    ModelDriven modelDriven = (ModelDriven) action;
    ValueStack stack = invocation.getStack();
    Object model = modelDriven.getModel();
    if (model != null) {
    stack.push(model);
    }
    if (refreshModelBeforeResult) {
    invocation.addPreResultListener(new RefreshModelBeforeResult(modelDriven, model));
    }
    }

    作用就是把模型驱动对象放入栈顶

岗位模块

  1. RoleDao

    1
    2
    3
    4
    5
    6
    7
    8
    package cn.itcast.shoa.dao;

    import cn.itcast.shoa.dao.base.BaseDao;
    import cn.itcast.shoa.domain.system.Role;

    public interface RoleDao extends BaseDao<Role>{

    }
  2. RoleDaoImpl

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    package cn.itcast.shoa.dao.impl;

    import org.springframework.stereotype.Repository;

    import cn.itcast.shoa.dao.RoleDao;
    import cn.itcast.shoa.dao.base.impl.BaseDaoImpl;
    import cn.itcast.shoa.domain.system.Role;

    @Repository("roleDao")
    public class RoleDaoImpl extends BaseDaoImpl<Role> implements RoleDao{

    }
  3. RoleService

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    package cn.itcast.shoa.service;

    import java.io.Serializable;
    import java.util.Collection;
    import cn.itcast.shoa.domain.system.Role;

    public interface RoleService {

    public Collection<Role> getAllRole();

    public Role getRoleById(Serializable id);

    public void saveRole(Role role);

    public void deleteRole(Serializable id);

    public void updateRole(Role role);

    }
  4. RoleServiceImpl

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    package cn.itcast.shoa.service.impl;

    import java.io.Serializable;
    import java.util.Collection;

    import javax.annotation.Resource;

    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    import cn.itcast.shoa.dao.RoleDao;
    import cn.itcast.shoa.domain.system.Role;
    import cn.itcast.shoa.service.RoleService;

    @Service("roleService")
    public class RoleServiceImpl implements RoleService{

    @Resource(name="roleDao")
    private RoleDao roleDao;

    @Override
    public Collection<Role> getAllRole() {
    // TODO Auto-generated method stub
    return this.roleDao.getAllEntry();
    }

    @Override
    public Role getRoleById(Serializable id) {
    // TODO Auto-generated method stub
    return this.roleDao.getEntryById(id);
    }

    @Transactional(readOnly=false)
    public void saveRole(Role role) {
    // TODO Auto-generated method stub
    this.roleDao.saveEntry(role);
    }

    @Transactional(readOnly=false)
    public void deleteRole(Serializable id) {
    // TODO Auto-generated method stub
    this.roleDao.deleteEntry(id);
    }

    @Transactional(readOnly=false)
    public void updateRole(Role role) {
    // TODO Auto-generated method stub
    this.roleDao.updateEntry(role);
    }

    }
  5. RoleAction

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    package cn.itcast.shoa.struts.action;

    import java.util.Collection;
    import java.util.Set;

    import javax.annotation.Resource;

    import org.springframework.beans.BeanUtils;
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Controller;

    import com.opensymphony.xwork2.ActionContext;

    import cn.itcast.shoa.domain.system.Department;
    import cn.itcast.shoa.domain.system.Role;
    import cn.itcast.shoa.domain.system.User;
    import cn.itcast.shoa.service.RoleService;
    import cn.itcast.shoa.struts.action.base.BaseAction;

    @Controller("roleAction")
    @Scope("prototype")
    public class RoleAction extends BaseAction<Role>{

    @Resource(name="roleService")
    private RoleService roleService;

    public String showAllRole() {
    //list集合必须放入值栈中才能用ognl表达式获取数据 两种做法:对象栈与map栈
    Collection<Role> roleList = this.roleService.getAllRole();
    //放入map
    ActionContext.getContext().put("roleList", roleList);
    return listAction;
    }

    public String addUI() {
    return addUI;
    }

    public String add() {
    Role role = new Role();
    /*
    * 把model的值赋值给department
    */
    BeanUtils.copyProperties(this.getModel(), role);
    this.roleService.saveRole(role);
    return action2action;
    }

    /**
    * 1. 提取department对象
    * 2. 获取该部门的所有的用户
    * @return
    */
    public String deleteRole() {
    this.roleService.deleteRole(this.getModel().getRid());
    return action2action;
    }

    public String updateUI() {
    //数据回显
    Role role = this.roleService.getRoleById(this.getModel().getRid());
    //放入栈顶
    ActionContext.getContext().getValueStack().push(role);
    return UPDATE_UI;
    }

    public String update() {
    Role role = this.roleService.getRoleById(this.getModel().getRid());
    BeanUtils.copyProperties(this.getModel(), role);
    this.roleService.updateRole(role);
    return action2action;
    }
    }
  6. struts.xml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

    <struts>
    <constant name="struts.devMode" value="true"/>
    <constant name="struts.ui.theme" value="simple"/>

    <include file="struts/struts-person.xml"></include>
    <include file="struts/struts-department.xml"></include>
    <include file="struts/struts-role.xml"></include>
    </struts>
  7. struts-role.xml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

    <struts>
    <package name="role" namespace="/" extends="struts-default">
    <action name="roleAction_*" method="{1}" class="roleAction">
    <result name="listAction">/WEB-INF/jsp/system/role/list.jsp</result>
    <result name="addUI">/WEB-INF/jsp/system/role/add.jsp</result>
    <result name="updateUI">/WEB-INF/jsp/system/role/update.jsp</result>
    <result name="action2action" type="redirectAction">roleAction_showAllRole.action</result>
    </action>
    </package>
    </struts>
  8. list.jsp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/jsp/common/common.jsp"%>
    <html>
    <head>
    <title>岗位列表</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>

    <div id="Title_bar">
    <div id="Title_bar_Head">
    <div id="Title_Head"></div>
    <div id="Title"><!--页面标题-->
    <img border="0" width="13" height="13" src="${pageContext.request.contextPath}/css/images/title_arrow.gif"/> 岗位管理
    </div>
    <div id="Title_End"></div>
    </div>
    </div>

    <div id="MainArea">
    <table cellspacing="0" cellpadding="0" class="TableStyle">

    <!-- 表头-->
    <thead>
    <tr align="CENTER" valign="MIDDLE" id="TableTitle">
    <td width="200px">岗位名称</td>
    <td width="300px">岗位说明</td>
    <td>相关操作</td>
    </tr>
    </thead>

    <!--显示数据列表-->
    <tbody id="TableData" class="dataContainer" datakey="roleList">
    <s:iterator value="#roleList">
    <tr class="TableDetail1 template">
    <td><s:property value="name"/></td>
    <td><s:property value="description"/></td>
    <td>
    <s:a action="roleAction_deleteRole.action?rid=%{rid}">删除</s:a>
    <s:a action="roleAction_updateUI.action?rid=%{rid}">修改</s:a>
    </td>
    </tr>
    </s:iterator>
    </tbody>
    </table>

    <!-- 其他功能超链接 -->
    <div id="TableTail">
    <div id="TableTail_inside">
    <a href="roleAction_addUI.action"><img src="${pageContext.request.contextPath}/css/images/createNew.png" /></a>
    </div>
    </div>
    </div>
    </body>
    </html>
  9. add.jsp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/jsp/common/common.jsp"%>
    <html>
    <head>
    <title>岗位设置</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>

    <!-- 标题显示 -->
    <div id="Title_bar">
    <div id="Title_bar_Head">
    <div id="Title_Head"></div>
    <div id="Title"><!--页面标题-->
    <img border="0" width="13" height="13" src="${pageContext.request.contextPath}/css/images/title_arrow.gif"/> 岗位设置
    </div>
    <div id="Title_End"></div>
    </div>
    </div>

    <!--显示表单内容-->
    <div id="MainArea">
    <s:form action="roleAction_add.action">
    <div class="ItemBlock_Title1"><!-- 信息说明<DIV CLASS="ItemBlock_Title1">
    <IMG BORDER="0" WIDTH="4" HEIGHT="7" SRC="${pageContext.request.contextPath}/css/blue/images/item_point.gif" /> 岗位信息 </DIV> -->
    </div>

    <!-- 表单内容显示 -->
    <div class="ItemBlockBorder">
    <div class="ItemBlock">
    <table cellpadding="0" cellspacing="0" class="mainForm">
    <tr>
    <td width="100">岗位名称</td>
    <td><s:textfield name="name" cssClass="InputStyle"></s:textfield></td>
    </tr>
    <tr>
    <td>岗位说明</td>
    <td><s:textarea name="description" cssClass="TextareaStyle"></s:textarea></td>
    </tr>
    </table>
    </div>
    </div>

    <!-- 表单操作 -->
    <div id="InputDetailBar">
    <input type="image" src="${pageContext.request.contextPath}/css/images/save.png"/>
    <a href="javascript:history.go(-1);"><img src="${pageContext.request.contextPath}/css/images/goBack.png"/></a>
    </div>
    </s:form>
    </div>

    </body>
    </html>
  10. update.jsp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/jsp/common/common.jsp"%>
    <html>
    <head>
    <title>岗位设置</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>

    <!-- 标题显示 -->
    <div id="Title_bar">
    <div id="Title_bar_Head">
    <div id="Title_Head"></div>
    <div id="Title"><!--页面标题-->
    <img border="0" width="13" height="13" src="${pageContext.request.contextPath}/css/images/title_arrow.gif"/> 岗位设置
    </div>
    <div id="Title_End"></div>
    </div>
    </div>

    <!--显示表单内容-->
    <div id="MainArea">
    <s:form action="roleAction_update.action">
    <s:hidden name="rid"></s:hidden>
    <div class="ItemBlock_Title1"><!-- 信息说明<DIV CLASS="ItemBlock_Title1">
    <IMG BORDER="0" WIDTH="4" HEIGHT="7" SRC="${pageContext.request.contextPath}/css/blue/images/item_point.gif" /> 岗位信息 </DIV> -->
    </div>

    <!-- 表单内容显示 -->
    <div class="ItemBlockBorder">
    <div class="ItemBlock">
    <table cellpadding="0" cellspacing="0" class="mainForm">
    <tr>
    <td width="100">岗位名称</td>
    <td><s:textfield name="name" cssClass="InputStyle"></s:textfield></td>
    </tr>
    <tr>
    <td>岗位说明</td>
    <td><s:textarea name="description" cssClass="TextareaStyle"></s:textarea></td>
    </tr>
    </table>
    </div>
    </div>

    <!-- 表单操作 -->
    <div id="InputDetailBar">
    <input type="image" src="${pageContext.request.contextPath}/css/images/save.png"/>
    <a href="javascript:history.go(-1);"><img src="${pageContext.request.contextPath}/css/images/goBack.png"/></a>
    </div>
    </s:form>
    </div>

    </body>
    </html>