添加角色—s

jsp:

<%@ page language="java" pageEncoding="GBK"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>

<title>新建角色</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath }/css/styles.css">
<script type="text/javascript">
//按钮操作
function doSubmit(o){
if(document.getElementById("role.roleName").value==""){
alert("角色名不得为空!");
return false;
}
document.forms[0].submit();
}
</script>
</head>

<body class="main">
<html:form action="/role?o=doAdd" method="post">
<div class="page_title">
权限管理 > 角色管理 > 新建角色
</div>
<div class="button_bar">
<button class="common_button" οnclick="javascript:history.go(-1);">
返回
</button>
<button class="common_button" οnclick="javascript:doSubmit('doAdd');">
保存
</button>
</div>
<table class="query_form_table" border="0" cellPadding="3"
cellSpacing="0">
<tr>
<th class="input_title">
角色名
</th>
<td class="input_content">
<html:text property="role.roleName" maxlength="" />
</td>
<th class="input_title">
角色描述
</th>
<td class="input_content">
<html:text property="role.roleDesc" maxlength="50" size="46" />
</td>
</tr>
<tr>
<th class="input_title">
权限
</th>
<td class="input_content">
未指定
</td>
<th class="input_title">
状态
</th>
<td class="input_content">
正常
<html:hidden property="role.roleFlag" value="1" />
</td>
</tr>
</table>
</html:form>
</body>
</html:html>

actionForm:

/*
* Generated by MyEclipse Struts Template path: templates/java/JavaClass.vtl
*/
package com.accp.crm.web.form.role;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.accp.crm.model.SysRole;
import com.accp.crm.web.form.BaseForm;

/**
* MyEclipse Struts Creation date: 12-15-2008
*
* XDoclet definition:
*
* @struts.form name="roleForm"
*/
public class RoleForm extends BaseForm {
/*
* Generated Methods
*/

private SysRole role = new SysRole();

private String[] rights; // 选中的权限代码

public String[] getRights() {
return rights;
}

public void setRights(String[] rights) {
this.rights = rights;
}

public SysRole getRole() {
return role;
}

public void setRole(SysRole role) {
this.role = role;
}

/**
* Method validate
*
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
return null;
}

/**
* Method reset
*
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
role = new SysRole();
}
}


action:
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
RoleForm roleForm = (RoleForm) form;
SysRole role = roleForm.getRole();
boolean bl = roleBiz.checkRoleName(role.getRoleName());
if (bl) {
request.setAttribute("operMessage", "角色已经存在!");
} else {
roleBiz.saveRole(role);
request.setAttribute("operMessage", "新建角色成功!");
}
roleForm.reset(mapping, request);
request.setAttribute("roleList", roleBiz.getRoleByPagination(roleForm
.getRole(), roleForm.getBean()));
return mapping.findForward("list");
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值