项目笔记:菜单和初始化
1、首先数据库jdbc配置:config路径下,配置jdbc,数据库名:jjfxxin,账户:root,密码:123456
2、菜单初始化设置:
//3.5.4服务中心-->应用商城-->正版序列号管理
Resource genuineSerialNumberManagement = new Resource("正版序列号管理", "正版序列号管理", "正版序列号管理", "sys_icon.png", "sys", "link", "genuineSerialNumberManagementAction_listUI.do", Integer.valueOf(30504), Integer.valueOf(3), createTime, updateTime, appstoreResource);
this.resourceDao.save(genuineSerialNumberManagement);
this.resourceDao.save(new Resource("添加序列号", "添加序列号", "添加序列号", "sys_system_add.png", "sys", "operate", "genuineSerialNumberManagementAction_addUI.do", Integer.valueOf(3050401), Integer.valueOf(4), createTime, updateTime, genuineSerialNumberManagement));
this.resourceDao.save(new Resource("修改序列号", "修改序列号", "修改序列号", "sys_system_add.png", "sys", "operate", "genuineSerialNumberManagementAction_editUI.do", Integer.valueOf(3050402), Integer.valueOf(4), createTime, updateTime, genuineSerialNumberManagement));
this.resourceDao.save(new Resource("删除序列号", "删除序列号", "删除序列号", "sys_system_add.png", "sys", "operate", "genuineSerialNumberManagementAction_delete.do", Integer.valueOf(3050403), Integer.valueOf(4), createTime, updateTime, genuineSerialNumberManagement));
this.resourceDao.save(new Resource("导入规则库", "导入规则库", "导入规则库", "sys_system_add.png", "sys", "operate", "genuineSerialNumberManagementAction_importUI.do", Integer.valueOf(3050404), Integer.valueOf(4), createTime, updateTime, genuineSerialNumberManagement));
this.resourceDao.save(new Resource("导出规则库", "导出规则库", "导出规则库", "sys_system_add.png", "sys", "operate", "genuineSerialNumberManagementAction_export.do", Integer.valueOf(3050405), Integer.valueOf(4), createTime, updateTime, genuineSerialNumberManagement));
代表层级下的子级目录等。
3、然后struts配置
<!-- 用户组管理 -->
<action name="userGroupAction_*" class="userGroupAction" method="{1}">
<result name="{1}">/WEB-INF/pages/userGroupAction/{1}.jsp</result>
<result name="toList" type="redirectAction">/userGroupAction_listUI.do</result>
</action>
<!-- 正版序列号管理 -->
<action name="genuineSerialNumberManagementAction_*" class="genuineSerialNumberManagementAction" method="{1}">
<result name="{1}">/WEB-INF/pages/genuineSerialNumberManagementAction/{1}.jsp</result>
<result name="toList" type="redirectAction">/genuineSerialNumberManagementAction_listUI.do</result>
</action>
4、在domain目录下新建xml和对应的实体类文件
和
XML里面对应数据库字段:table表示会新建的数据库表的名字
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.vrv.paw.domain">
<class name="GenuineSerialNumberManagement" table="vrv_paw_genuineSerialNumberManagement">
<cache usage="transactional" />
<id name="id" column="id" type="integer">
<generator class="native" />
</id>
<property name="softId" type="integer"/>
<property name="version" type="string" length="255" />
<property name="serialNumber" type="string" length="255" />
<property name="softDisplayName" type="string" length="64" />
<property name="type" type="integer"/>
</class>
</hibernate-mapping>
数据库字段:
实体类文件对应XML里面的设置的属性和其get和set方法:此处注意:get/set方法最好用eclipse自动生成,自己写有时候错了,不容易找到问题
package com.vrv.paw.domain;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
public class GenuineSerialNumberManagement<T> implements Serializable {
private static final long serialVersionUID = -8509177078853219369L;
//序号
private Integer id;
//软件id号
private Integer softId;
//版本号
private String version;
//序列号
private String serialNumber;
//软件名
private String softDisplayName;
//黑白名单类型
private Integer type;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getSoftId() {
return softId;
}
public void setSoftId(Integer softId) {
this.softId = softId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public String getSoftDisplayName() {
return softDisplayName;
}
public void setSoftDisplayName(String softDisplayName) {
this.softDisplayName = softDisplayName;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public GenuineSerialNumberManagement() {
super();
}
public GenuineSerialNumberManagement(Integer softId, String version, String serialNumber, String softDisplayName,
Integer type) {
this.softId = softId;
this.version = version;
this.serialNumber = serialNumber;
this.softDisplayName = softDisplayName;
this.type = type;
}
}
5、数据库初始化:初始化的时候注意xml要和实体类里面一一对应,否则会出错
删除该表,并重新建一个空表,运行项目初始化。
6、授权:
初始化之后菜单暂时并不会出现我们设置的菜单,还需要该项目授权
授权之后将生成的menu.properties文件拷贝覆盖原先的文件即可出现设置的菜单项。
启动成功,in 1517ms,注意http的端口号是:8880,而不是8080
在此处改了端口号