ssh项目--资产管理系统

目录

说明

  1. 简单的资产管理模块:
    资产类别管理(增删改查)
    资产信息管理(增删改查)
    人员信息管理(增删改查)
    资产领用管理(增查)
    资产归还管理(增查)
    资产报废管理(增查)
  2. 数据库表:
    资产类别表(编号,大类别,小类别)
    资产信息表(编号,名称,价格,时间,状态,备注)
    人员信息表(编号,姓名,密码,性别,部门,职位,其他)
    资产领用表(编号,领用人,用途,备注)时间,操作人
    资产归还表(编号,操作人,备注)时间
    资产报废表(编号,操作人,备注)时间
  3. 数据表关系
    资产信息表和资产类别表:多对一
    资产领用表和资产信息表:一对一
    资产归还表和资产领用表:一对一
    资产报废表和资产信息表:一对一
  4. 数据库是Access数据库
  5. spring使用注解方式

下面内容只举资产信息管理(增删改查)一个模块(其他功能类似,篇幅有限)

项目的结构

图片:
结构
结构2

包1
包2

配置web.xml

在整合ssh框架时需要先在web.xml中分别配置struts和spring,代码片.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	id="WebApp_ID" version="3.0">
	<display-name>web-ssh</display-name>
	
	<!-- 设置编码方式 -->
	<filter>
		<filter-name>CharacterEncodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>CharacterEncodingFilter</filter-name>
		<url-pattern>/ *</url-pattern>
	</filter-mapping>


	<!-- 配置Spring的OpenSessionInViewFilter过滤器,以解决Hibernate的懒加载异常(LazyInitializationException) -->
    <filter>
       <filter-name>OpenSessionInViewFilter</filter-name>
    <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
    </filter>
    <filter-mapping>
       <filter-name>OpenSessionInViewFilter</filter-name>
       <url-pattern>*.action</url-pattern>
    </filter-mapping>

	<!-- 设置struts2核心拦截器 -->
	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/ *</url-pattern>
	</filter-mapping>
	
	<!-- 设置spring监听器,可以在bean中使用内置对象 -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
	<!-- 设置spring监听器-->
	<listener>
		<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
	</listener>
	<!-- 引入spring核心配置文件-->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</context-param>
</web-app>

配置struts.xml

配置struts的struts.xml,使用通配符的方式来访问action,代码片.

<?xml version="1.0" encoding="UTF-8"?>

<!-- 引入文档类型 -->
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
	<!-- 全局属性 -->
	<constant name="struts.il8n.encoding" value="UTF-8"></constant>
	
	<package name="strutsOne" extends="struts-default" namespace="">


	<!-- utilization -->
		<action name="utilization_*" class="assetByUtilizationAction" method="{1}">
			<result name="success" type="redirect">
				<!-- OGNL表达式 -->
				<param name="Location">${#request.result}</param>
			</result>
			<result name="xxx" type="redirect">/login.html</result>
			<result name="input">/save_user.jsp</result>
		</action>
		
	<!-- asset -->
		<action name="asset_*" class="assetAction" method="{1}">
			<result name="success" type="redirect">
				<!-- OGNL表达式 -->
				<param name="Location">${#request.result}</param>
			</result>
			<result name="xxx" type="redirect">/login.html</result>
			<result name="input">/save_user.jsp</result>
		</action>
		
	<!-- assetsReturn -->
		<action name="assetsReturn_*" class="assetsReturnAction" method="{1}">
			<result name="success" type="redirect">
				<!-- OGNL表达式 -->
				<param name="Location">${#request.result}</param>
			</result>
			<result name="xxx" type="redirect">/login.html</result>
			<result name="input">/save_user.jsp</result>
		</action>
		
	<!-- scrap -->
		<action name="scrap_*" class="scrapAction" method="{1}">
			<result name="success" type="redirect">
				<!-- OGNL表达式 -->
				<param name="Location">${#request.result}</param>
			</result>
			<result name="xxx" type="redirect">/login.html</result>
			<result name="input">/save_user.jsp</result>
		</action>
		
	<!-- system__type -->
		<action name="type_*" class="systemAction" method="{1}">
			<result name="success" type="redirect">
				<!-- OGNL表达式 -->
				<param name="Location">${#request.result}</param>
			</result>
			<result name="xxx" type="redirect">/login.html</result>
			<result name="input">/save_user.jsp</result>
		</action>
		
	<!-- user -->
		<action name="user_*" class="userAction" method="{1}">
			<result name="success" type="redirect">
				<!-- OGNL表达式 -->
				<param name="Location">${#request.result}</param>
			</result>
			<result name="xxx" type="redirect">/login.html</result>
			<result name="input">/save_user.jsp</result>
		</action>	
	</package>
</struts>

配置applicationContext.xml

配置spring的applicationContext.xml,代码片.

<?xml version="1.0" encoding="UTF-8"?>
<!-- 引入约束 -->
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd">

	<!-- 开启注解扫描 -->
	<!-- <context:annotation-config / > -->
	<!-- 开启注解扫描,不能用*表示所有包 -->
	<context:component-scan base-package="com.*" />
	
	<!-- 开启注解AOP -->
	<aop:aspectj-autoproxy />
	
	<!-- 引入外部文件 -->
	<context:property-placeholder location="classpath:jdbc.properties" />
	
	<!-- 配置连接池 c3p0-->
	<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass" value="${jdbc.driver}" />
		<property name="jdbcUrl" value="${jdbc.url}" />
		<property name="user" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>
	
	<!-- 配置hibernate session工厂 -->
	<bean name="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<!-- 引入连接池 -->
		<property name="dataSource" ref="dataSource"></property>
		<!-- 设置hibernate 连接属性 -->
		<property name="hibernateProperties">
			<props>
				<!-- 方言 -->
				<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
				<!-- 打印sql语句 -->
				<prop key="hibernate.show_sql">true</prop>
				<!-- 输出格式化 -->
				<prop key="hibernate.format_sql">true</prop>
				<!-- 操作数据的方式 update create -->
				<prop key="hibernate.hbm2ddl.auto">update</prop>
				<!--connection.characterEncoding连接数据库时数据的传输字符集编码方式-->
				<prop key="connection.characterEncoding">utf-8</prop>
			</props>
		</property>
		<!-- 引入hibernate的映射文件 -->
		<property name="mappingResources">
			<list>
				<value>entity/Asset.hbm.xml</value>
				<value>entity/Return.hbm.xml</value>
				<value>entity/Scrap.hbm.xml</value>
				<value>entity/Type.hbm.xml</value>
				<value>entity/User.hbm.xml</value>
				<value>entity/Utilization.hbm.xml</value>
			</list>
		</property>
	</bean>

	<!-- 配置spring JDBC模板 -->
	<bean name="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource" ref="dataSource"/>
	</bean>
	
	<!-- 配置事务管理器 -->
	<bean name="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"/>
	</bean>
	
	<!-- 开启注解事务 -->
	<tx:annotation-driven transaction-manager="transactionManager" />
	
</beans>

配置Asser.hbm.xml

配置hibernate的XXX.hbm.xml,我是在eclipse中使用了hibernate插件来做的,hibernate不分大小写,代码片.

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2019-8-11 20:05:57 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
    <class name="entity.Asset" table="asset">
        <id name="aid" type="int">
            <column name="aid" />
            <generator class="identity" />
        </id>
        <property name="aname" type="java.lang.String">
            <column name="aname" />
        </property>
        <property name="aprice" type="double">
            <column name="aprice" />
        </property>
        <property name="adate" type="java.lang.String">
            <column name="ADATE" />
        </property>
        <property name="astatu" type="java.lang.String">
            <column name="astatu" />
        </property>
        <property name="aremark" type="java.lang.String">
            <column name="aremark" />
        </property>
        <!-- 级联操作添加,更新,all指全部:cascade="save-update,persist" 关闭懒加载(默认为真):lazy="false" -->
        <many-to-one name="type" class="entity.Type" fetch="join"  >
            <column name="type" />
        </many-to-one>
    </class>
</hibernate-mapping>

配置jdbc.properties

配置连接数据库的资源文件的jdbc.properties,代码片.

jdbc.driverClass=com.hxtt.sql.access.AccessDriver
jdbc.url=jdbc:Access:///F:HrMS.accdb
jdbc.username=
jdbc.password=

Action层:AsserAction.java

Action类,代码片.

 package com.action;

import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.service.AssetService;

import entity.Asset;

@Controller
@Scope("prototype")
public class AssetAction extends ActionSupport implements ModelDriven<Asset> {

	private Asset asset = new Asset();
	@Autowired
	private AssetService service ;		
	public void setService(AssetService service) {
		this.service = service;
	}

	@Override
	public Asset getModel() {

		// TODO Auto-generated method stub
		return asset;
	}

	// 按id查找
	public String findByid() {
		
		Integer id = new Integer(ServletActionContext.getRequest().getParameter("id"));
		Asset arg1=service.findByid(id);
		if(arg1!=null){
			ServletActionContext.getRequest().getSession().setAttribute("asset", arg1);
			ServletActionContext.getRequest().setAttribute("result", "/jsp/Asset/Asset-update.jsp");
		}else{
			ServletActionContext.getRequest().getSession().setAttribute("ms", "id输入错误");
			ServletActionContext.getRequest().setAttribute("result", "/jsp/Asset/Asset-update.jsp");
		}
		return SUCCESS;
		
	}

	// 查找全部
	public String findAll() {
		List<Asset> arg1 = service.findAll();
		ServletActionContext.getRequest().getSession().setAttribute("assets", arg1);
		ServletActionContext.getRequest().setAttribute("result", "/jsp/Asset/Query/Asset-findAll.jsp");
		return SUCCESS;
	}

	// 分页查找,n当前页
	public String listOfPage() {
		Integer n=new Integer(ServletActionContext.getRequest().getParameter("n"));
		if(n==0||n==null){
			n=1;
		}
		List<Asset> arg1 = service.listOfPage(n);
		ServletActionContext.getRequest().getSession().setAttribute("assets", arg1);
		ServletActionContext.getRequest().setAttribute("result", "/jsp/Asset/Query/Asset-findAll.jsp");
		return SUCCESS;
	}

	// 添加
	public String save() {
		// TODO Auto-generated method stub
		service.save(asset);
		ServletActionContext.getRequest().setAttribute("result", "asset_findAll");
		return SUCCESS;
	}

	// 修改
	public String update() {
		// TODO Auto-generated method stub
		service.update(asset);
		ServletActionContext.getRequest().setAttribute("result", "asset_findAll");
		return SUCCESS;
	}

	// 删除
	public String delete() {
		// TODO Auto-generated method stub
		Integer id=new Integer(ServletActionContext.getRequest().getParameter("id"));
		service.delete(id);
		ServletActionContext.getRequest().setAttribute("result", "asset_findAll");
		return SUCCESS;

	}
}

注意:
1. action类继承 ActionSupport,来定义action类。
2. 实现接口ModelDriven接口来实例化实体类。
3. 注解定义action

Service层:AsserService.java

Service类,代码片.

package com.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dao.AssetDAO;

import entity.Asset;

@Transactional
@Service
public class AssetService{

	@Autowired
	private AssetDAO dao;
	
	public void setDao(AssetDAO dao) {
		this.dao = dao;
	}

	// 按id查找
	public Asset findByid(Integer id) {
		return dao.findByid(id);
	}

	// 查找全部
	public List<Asset> findAll() {
		return dao.findAll();
	}

	// 分页查找,n当前页
	public List<Asset> listOfPage(Integer n) {

		return dao.listOfPage(n);
	}

	// 添加
	public void save(Asset asset) {
		// TODO Auto-generated method stub
		dao.save(asset);
	}

	// 修改
	public void update(Asset asset) {
		// TODO Auto-generated method stub
		dao.update(asset);
	}

	// 删除
	public void delete(Integer id) {
		// TODO Auto-generated method stub
		dao.delete(id);

	}
}

注意:
在Service层使用-事务管理(在类上要配置一下)

DAO层:AsserDAO.java

DAO类,代码片.

package com.dao;

import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import entity.Asset;

@Repository
public class AssetDAO {

	@Autowired
	private SessionFactory sessionFactory;

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	// 按id查找
	public Asset findByid(Integer id) {
		Session session = sessionFactory.getCurrentSession();
		Asset asset = (Asset) session.get(Asset.class, id);
		return asset;
	}

	// 查找全部
	public List<Asset> findAll() {
		Session session = sessionFactory.getCurrentSession();
		Criteria criteria = session.createCriteria(Asset.class);
		@SuppressWarnings("unchecked")
		List<Asset> assets = criteria.list();
		return assets;
	}

	// 分页查找,n当前页
	public List<Asset> listOfPage(Integer n) {
		int s = this.findAll().size();
		if (s % 6 == 0) {
			s = s / 6;
		} else {
			s = s / 6 + 1;
		}
		ServletActionContext.getRequest().getSession().setAttribute("conPage", s);// 设置总页数
		Session session = sessionFactory.getCurrentSession();
		Criteria criteria = session.createCriteria(Asset.class);
		Integer integer = new Integer((n - 1) * 6);// 查询起点
		// 起点必须是大小等于0的数,否则报错
		criteria.setFirstResult(integer);
		criteria.setMaxResults(6);// 查询数目
		@SuppressWarnings("unchecked")
		List<Asset> assets = criteria.list();
		return assets;
	}

	// 分页查找,n当前页Query
	public List<Asset> listOfPage_Query(int n) {
		int s = this.findAll().size();
		if (s % 6 == 0) {
			s = s / 6;
		} else {
			s = s / 6 + 1;
		}
		ServletActionContext.getRequest().getSession().setAttribute("conPage", s);// 设置总页数
		String hql = "select u from Asset u";
		// 不把映射文件加入框架中,不能使用Query
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery(hql);
		Integer integer = new Integer((n - 1) * 6);// 查询起点
		query.setFirstResult(integer);
		query.setMaxResults(6);// 查询最大数目
		@SuppressWarnings("unchecked")
		List<Asset> assets = query.list();
		return assets;
	}

	// 添加
	public void save(Asset asset) {
		// TODO Auto-generated method stub
		Session session = sessionFactory.getCurrentSession();
		session.save(asset);
	}

	// 修改
	public void update(Asset asset) {
		// TODO Auto-generated method stub
		Session session = sessionFactory.getCurrentSession();
		session.update(asset);
	}

	// 删除
	public void delete(Integer id) {
		// TODO Auto-generated method stub
		Session session = sessionFactory.getCurrentSession();
		Asset asset = (Asset) session.get(Asset.class, new Integer(id));
		session.delete(asset);
	}
}

注意:
1. 使用hibernate的API来操作数据库。
2. 在session.createQuery(“查询语句”)返回的是实体对象的集合。

Entity层:Asser.java

实体类,代码片.

package entity;

public class Asset {
	private int aid;//领用编号
	private String aname;//资产名
	private double aprice;//资产价格
	private String adate;//购买日期
	private String astatu;//状态
	private String aremark;//备注
	private Type type;//资产类型
	public int getAid() {
		return aid;
	}
	public void setAid(int aid) {
		this.aid = aid;
	}
	public String getAname() {
		return aname;
	}
	public void setAname(String aname) {
		this.aname = aname;
	}
	public double getAprice() {
		return aprice;
	}
	public void setAprice(double aprice) {
		this.aprice = aprice;
	}
	public String getAdate() {
		return adate;
	}
	public void setAdate(String adate) {
		this.adate = adate;
	}
	public String getAstatu() {
		return astatu;
	}
	public void setAstatu(String astatu) {
		this.astatu = astatu;
	}
	public String getAremark() {
		return aremark;
	}
	public void setAremark(String aremark) {
		this.aremark = aremark;
	}
	public Type getType() {
		return type;
	}
	public void setType(Type type) {
		this.type = type;
	}
	@Override
	public String toString() {
		return "Asset [aid=" + aid + ", aname=" + aname + ", aprice=" + aprice + ", adate=" + adate + ", astatu="
				+ astatu + ", aremark=" + aremark + ", type=" + type + "]";
	}
	
}

总界面.html

总界面,代码片.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>资产管理系统</title>
<style type="text/css">
<!--
@import url(css/head.CSS); /*这里是通过@import引用CSS的样式内容*/
-->
</style>
</head>
<body>
	<!-- <link rel="stylesheet" type="text/css" href="head.CSS">-->
	<div class="main">
		<!--头部-->
		<div class="header">
			<div class="head-nav">
				<div class="head-nav-con clearFloat">
					<ul>
						<li><a href="head-main.html" tabindex="head-main">首页</a></li>

						<li class="drop-down"><a href="#">系统管理</a>
							<hr />
							<ul class="drop-down-content">
								<li><a href="type_findAll.action">类别管理</a></li>
								<li><a href="jsp/System-use/Exit.jsp">退出</a></li>
							</ul></li>
						<li class="drop-down"><a href="#">资产信息管理</a>
							<hr />
							<ul class="drop-down-content">
								<li class="drop-down-2"><a href="#">查询资产信息</a>
									<ul class="drop-down-content-2">
										<li><a href="asset_findAll.action" tabindex="head-main">查询所有资产信息</a></li>
										<li><a href="jsp/Asset/Query/Asset-findById.jsp">编号查询资产信息</a></li>
									</ul></li>
								<hr />
								<li><a href="jsp/Asset/Asset-save.jsp" tabindex="head-main">资产信息增加</a></li>
								<li><a href="jsp/Asset/Asset-update.jsp"
									tabindex="head-main">资产信息修改</a></li>
								<li><a href="jsp/Asset/Asset-delete.jsp"
									tabindex="head-main">资产信息删除</a></li>
							</ul></li>
						<li class="drop-down"><a href="#">人员信息管理</a>
							<hr />
							<ul class="drop-down-content">
								<li class="drop-down-2"><a href="#">查询人员信息</a>
									<ul class="drop-down-content-2">
										<li><a href="user_findAll.action">查询所有人员信息</a></li>
										<li><a href="jsp/User/Query/User-findById.jsp"
											tabindex="head-main">编号查询人员信息</a></li>
									</ul></li>
								<hr />
								<li><a href="jsp/User/User-save.jsp" tabindex="head-main">人员信息增加</a></li>
								<li><a href="jsp/User/User-update.jsp" tabindex="head-main">人员信息修改</a></li>
								<li><a href="jsp/User/User-delete.jsp" tabindex="head-main">人员信息删除</a></li>
							</ul></li>
						<li class="drop-down"><a href="#">资产领用</a>
							<hr>
							<ul class="drop-down-content">
								<li><a href="utilization_findAll.action">领用信息查询</a></li>
								<hr />
								<li><a href="utilization_findAllAsset.action">资产使用管理</a></li>

							</ul></li>
						<li class="drop-down"><a href="#">资产归还</a>
							<hr>
							<ul class="drop-down-content">
								<li><a href="assetsReturn_findAll.action"
									tabindex="head-main">归还信息查询</a></li>
								<hr />
								<li><a href="jsp/Assets-Return/Assets-Return-Query.jsp"
									tabindex="head-main">资产归还管理</a></li>

							</ul></li>
						<li class="drop-down"><a href="#">资产报废</a>
							<hr>
							<ul class="drop-down-content">
								<li class=""><a href="scrap_findAll.action">报废信息查询</a></li>
								<hr />
								<li><a href="jsp/Scrap/Scrap-Query.jsp"
									tabindex="head-main">资产报废管理</a></li>
							</ul></li>
					</ul>
				</div>
			</div>
		</div>
	</div>
	<br />
	<br />
</body>
</html>

查询界面.jsp

查询界面,代码片.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>	
<!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>查询所有资产信息</title>
<style type="text/css">
<!--
@import url(../../../css/head.CSS); /*这里是通过@import引用CSS的样式内容*/
-->
</style>
</head>

<body>
	<%@include file="../../../css/head.jsp"%>
	
	<div align="center">
	<h3>查询所有资产信息</h3>
	<br/>
		<table border="1">
			<tr>
				<td>编号</td>
				<td>资产名称</td>
				<td>大类型</td>
				<td>小类型</td>
				<td>资产价格</td>
				<td>购买日期</td>
				<td>资产状态</td>
				<td>备注</td>
			</tr>
			<c:forEach var="asset" items="${assets}">
				<tr>
					<td>${asset.aid}</td>
					<td>${asset.aname}</td>
					<td>${asset.type.tgname}</td>
					<td>${asset.type.tlname}</td>
					<td>${asset.aprice}</td>
					<td>${asset.adate}</td>
					<td>${asset.astatu}</td>
					<td>${asset.aremark}</td>
					<td><a href="../Asset-save.jsp">增加</a> <a
						href="asset_delete.action?id=${asset.aid}">删除</a> <a
						href="asset_findByid.action?id=${asset.aid}">修改</a></td>
				</tr>
			</c:forEach>
		</table><c:forEach begin="1" end="${conPage}" var="x">
			<a href="asset_listOfPage?n=${x}">${x}</a>
		</c:forEach></div>	
</body>
</html>

注意:
属性名要使用对象.属性的方式。

添加界面.jsp

添加界面,代码片.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>	
<!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>资产信息增加</title>
<style type="text/css">
<!--
@import url(../../css/head.CSS); /*这里是通过@import引用CSS的样式内容*/
-->
</style>
</head>

<body>
	<%@include file="../../css/head.jsp"%>
	<div align="center"> 
	<h3 align="center">资产信息增加</h3>
	<br/>
	<form action="asset_save.action" method="post">
	
				资产名称:<input type="text" name="aname"/>
    	<br/>&nbsp;&nbsp;&nbsp;型:<input type="text" name="type.tgname"/>
    	<br/>&nbsp;&nbsp;&nbsp;型:<input type="text" name="type.tlname"/>
    	<br/>
				资产价格:<input type="text" name="aprice"/>
    	<br/>
				购买日期:<input type="text" name="adate"/>
    	<br/>
				资产状态:<input type="text" name="astatu"/>
    	<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:<input type="text" name="aremark"/>
    	<br/>
		<input type="submit" value="提交" /> 
		<input type="reset" value="重置" />
	</form>
	</div>
</body>
</html>

修改界面.jsp

修改界面,代码片.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>	
<!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>资产信息修改</title>
<style type="text/css">
<!--
@import url(../../css/head.CSS); /*这里是通过@import引用CSS的样式内容*/
-->
</style>
</head>

<body>
	<%@include file="../../css/head.jsp"%>
	<div align="center"> 
	<h3 align="center">资产信息修改</h3>
	<br/>
	<form action="asset_update.action" method="post">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:<input type="text" value="${asset.aid}" name="aid" readonly="readonly"/>
    	<br/>
				资产名称:<input type="text" value="${asset.aname}" name="aname"/>
    	<br/>
				大类型:<input type="text" value="${asset.type.tgname}" name="type.tgname"/>
    	<br/>
				小类型:<input type="text" value="${asset.type.tlname}" name="type.tlname"/>
    	<br/>
				资产价格:<input type="text" value="${asset.aprice}" name="aprice"/>
    	<br/>
				购买日期:<input type="text" value="${asset.adate}" name="adate"/>
    	<br/>
				资产状态:<input type="text" value="${asset.astatu}" name="astatu"/>
    	<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:<input type="text" value="${asset.aremark}" name="aremark"/>
    	<br/>
		<input type="submit" value="提交" /> 
		<input type="reset" value="重置" />
	</form>
	</div>
</body>
</html>

删除界面.jsp

删除界面,代码片.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>	
<!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>资产信息删除</title>
<style type="text/css">
<!--
@import url(../../css/head.CSS); /*这里是通过@import引用CSS的样式内容*/
-->
</style>
</head>

<body>
	<%@include file="../../css/head.jsp"%>
	<div align="center"> 
	<h3 align="center">资产信息删除</h3>
	<br/>
	<form action="asset_delete.action" method="post">
	
		编号:<input type="text" name="id"/>
    	<br/>
		<input type="submit" value="提交" /> 
		<input type="reset" value="重置" />
	</form>
	</div>
</body>
</html>

总结

	1. 乱码问题。
	2. 使用hibernate 操作问题。
	3. hibernate映射配置问题。
	4. 级联操作问题。
	5. 访问路径问题,命名不要使用java保留字,不要用-。
	6. 多看异常,要有信心
**引用包是最大的困难(一步一步来)**
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值