SSH----------保存权限表数据

1、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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<!-- 导入jquery核心类库 -->
<script type="text/javascript"
   src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<!-- 导入easyui类库 -->
<link rel="stylesheet" type="text/css"
   href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
   href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css"
   href="${pageContext.request.contextPath }/js/easyui/ext/portal.css">
<link rel="stylesheet" type="text/css"
   href="${pageContext.request.contextPath }/css/default.css">    
<script type="text/javascript"
   src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
   src="${pageContext.request.contextPath }/js/easyui/ext/jquery.portal.js"></script>
<script type="text/javascript"
   src="${pageContext.request.contextPath }/js/easyui/ext/jquery.cookie.js"></script>
<script
   src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"
   type="text/javascript"></script>
<script type="text/javascript">
   $(function(){
      // 点击保存
      $('#save').click(function(){
         //location.href='${pageContext.request.contextPath}/page_admin_function.action';
         $('#functionForm').submit();

      });
   });
</script>  
</head>
<body class="easyui-layout">
<div data-options="region:'north'">
   <div class="datagrid-toolbar">
      <a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true" >保存</a>
   </div>
</div>
<div data-options="region:'center'">
   <form id="functionForm" method="post" action="${pageContext.request.contextPath}/FunctionAction_save.action">
            <table class="table-edit" width="80%" align="center">
               <tr class="title">
                  <td colspan="2">功能权限信息</td>
               </tr>
               <tr>
                  <td width="200">名称</td>
                  <td>
                     <input type="text" name="name" class="easyui-validatebox" data-options="required:true" />
                  </td>
               </tr>
               <tr>
                  <td>关键字</td>
                  <td><input type="text" name="code" class="easyui-validatebox" data-options="required:true" /></td>
               </tr>
               <tr>
                  <td>访问路径</td>
                  <td><input type="text" name="page"  /></td>
               </tr>
               <tr>
                  <td>是否生成菜单</td>
                  <td>
                     <select name="generatemenu" class="easyui-combobox">
                        <option value="0">不生成</option>
                        <option value="1">生成</option>
                     </select>
                  </td>
               </tr>
               <tr>
                  <td>优先级</td>
                  <td>
                     <input type="text" name="zindex" class="easyui-numberbox" data-options="required:true" />
                  </td>
               </tr>
               <tr>
                  <td>父功能点</td>
                  <td>
                     <input name="function.id" class="easyui-combobox" data-options="valueField:'id',textField:'name',url:'${pageContext.request.contextPath}/FunctionAction_listJson.action'"/>
                  </td>
               </tr>
               <tr>
                  <td>描述</td>
                  <td>
                     <textarea name="description" rows="4" cols="60"></textarea>
                  </td>
               </tr>
               </table>
         </form>
</div>
</body>
</html>

2、action

package com.dong.bos.web.action;

import com.dong.bos.model.Function;
import com.dong.bos.model.User;
import com.dong.bos.utils.MD5Utils;
import com.dong.bos.web.action.base.BaseAction;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class FunctionAction extends BaseAction<Function> {

    public void pageQuery() throws IOException {
        //1.接收参数 page[当前页] rows[每页显示多少条]
        //封装条件
 pb.setCurrentPage(Integer.valueOf(getModel().getPage()));//BaseAction和Function中都有page,会优先存储到Function
        pb.setPageSize(rows);

        //2.调用service,参数里传一个PageBean
        iFunctionService.pageQuery(pb);

        //3.返回json数据
        RespJson(pb,new String[]{"currentPage","pageSize","detachedCriteria","function","functions"});

    }

    @Override
    public String save() {
        iFunctionService.save(getModel());
        return NONE;
    }

    @Override
    public String update() {
        return null;
    }

    @Override
    public String delete() throws IOException {
        return null;
    }

    @Override
    public String list() {
        return null;
    }

    public String listJson() throws IOException {
       List<Function> functionList=iFunctionService.findAll();
       RespJson(functionList,new String[]{"function","functions","roles"});
        return NONE;
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值