SSM项目--资产管理系统

这篇博客是上一篇SSH的姊妹篇,同一个项目的不同实现框架,可以比对一下,比较SSH和SSM的整合的异同和流程。

目录

说明

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

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

项目的结构

图片:
结构1
结构2
包

配置web.xml

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

<?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"
	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-ssm</display-name>
	

	<!-- 设置编码方式 拦截器 -->
	<filter>
		<filter-name>CharacterEncodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>CharacterEncodingFilter</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 核心监听器 获取spring上下文 -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- 加载spring 核心配置文件 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</context-param>

	<!-- 配置spring MVC 视图servlet 获取页面请求 -->
	<servlet>
		<servlet-name>MyDispatcher</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:springmvc.xml</param-value>
		</init-param>
		
	</servlet>
	<servlet-mapping>
		<servlet-name>MyDispatcher</servlet-name>
		<url-pattern>*.action</url-pattern>
	</servlet-mapping>
</web-app>

配置springmvc.xml

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

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="    
            http://www.springframework.org/schema/util   
            http://www.springframework.org/schema/util/spring-util-3.2.xsd  
            http://www.springframework.org/schema/mvc   
            http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd  
            http://www.springframework.org/schema/beans         
            http://www.springframework.org/schema/beans/spring-beans-3.2.xsd    
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-3.2.xsd">

	<!-- 开启mvc注解 -->
	<mvc:annotation-driven />

	<!-- 开启注解扫描 -->
	<context:component-scan base-package="com.*" />

	<!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
	<!-- ViewResolver 视图 -->
	<bean  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
		<!-- 返回视图前缀 -->
		<property name="prefix" value=""></property>
		<!-- 返回视图后缀 -->
		<property name="suffix" value=".jsp"></property>
	</bean>
</beans>

配置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:component-scan base-package="com.*" />

	<!-- 开启AOP注解 -->
	<aop:aspectj-autoproxy />

	<!-- 引入外部资源文件 -->
	<!-- 读取解析properties文件 -->
	<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location">
			<value>classpath:jdbc.properties</value>
		</property>
	</bean>

	<!-- 配置数据源 spring 自带 -->
	<bean name="dataSource"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>

	<!-- 配置 sqlSessionFactory 工厂 mybatis操作数据库 -->
	<bean name="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 注入连接池 -->
		<property name="dataSource" ref="dataSource" />
		<!-- 引入mybatis核心配置文件 -->
		<property name="configLocation">
			<value>classpath:mybatisConf.xml</value>
		</property>
		
		<!-- 当mybatis的xml文件和mapper接口不在相同包下时,需要用mapperLocations属性指定xml文件的路径。 *是个通配符,代表所有的文件,**代表所有目录下 -->
		
		<!-- 结论是:如果Mapper.xml与Mapper.class在同一个包下且同名,spring扫描Mapper.class的同时会自动扫描同名的Mapper.xml并装配到Mapper.class。
			如果Mapper.xml与Mapper.class不在同一个包下或者不同名,就必须使用配置mapperLocations指定mapper.xml的位置。
			此时spring是通过识别mapper.xml中的 <mapper namespace="com.fan.mapper.UserDao"> namespace的值来确定对应的Mapper.class的。
 		-->
		<!-- 和下面的扫描mapper对应 -->
		<property name="mapperLocations" value="classpath:com/dao/*.xml" />
		<!-- 设置别名 ,默认包下的类名-->
		<property name="typeAliasesPackage" value="entity" />

	</bean>

	<!-- 配置mapper工厂 -->
	<!-- <bean class="org.mybatis.spring.mapper.MapperFactoryBean"> -->
	<!-- mapper  (需要代理的接口) -->
	<!-- <property name="mapperInterface" value="com.dao.UserDao" /> -->
	<!-- 注入 sqlSessionFactory 工厂 -->
	<!-- <property name="sqlSessionFactory" ref="sqlSessionFactory"/> -->
	<!-- </bean> -->

	<!-- 扫描mapper -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.dao" />
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
	</bean>

	<!-- 配置事务管理 spring jdbc 事务管理器 -->
	<bean name="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<!-- 开启注解事务 -->
	<tx:annotation-driven transaction-manager="transactionManager" />

</beans>

配置mybatisConf.xml

整合后不需要配置这个了,但是如果需要设置mybatis的一些属性,还是需要在这里面配置。

<?xml version="1.0" encoding="UTF-8"?>
<!-- 引入文档 -->
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">

<!-- 注意:每个标签必须按错误提示的顺序写,不然蛋疼的DTD会提示错误: The content of element type "configuration" 
	must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,plugins?,environments?,mappers?)". -->
<configuration>
	<!-- 设置mybetis运行时的行为 
	<settings>-->
		<!-- 全局地开启或关闭配置文件中的所有映射器已经配置的任何缓存。
		<setting name="cacheEnabled" value="true" /> -->
		
		<!-- 延迟加载的全局开关。当开启时,所有关联对象都会延迟加载。 特定关联关系中可通过设置fetchType属性来覆盖该项的开关状态。 
		<setting name="lazyLoadingEnabled" value="true" />-->
		
		<!-- 是否允许单一语句返回多结果集(需要兼容驱动)。
		<setting name="multipleResultSetsEnabled" value="true" /> -->
		
		<!-- 使用列标签代替列名。不同的驱动在这方面会有不同的表现, 具体可参考相关驱动文档或通过测试这两种不同的模式来观察所用驱动的结果。
		<setting name="useColumnLabel" value="true" /> -->
		
		<!-- 允许 JDBC 支持自动生成主键,需要驱动兼容。 如果设置为 true
		则这个设置强制使用自动生成主键,尽管一些驱动不能兼容但仍可正常工作(比如 Derby)。
		<setting name="useGeneratedKeys" value="false" /> -->
		
		<!-- 指定 MyBatis 应如何自动映射列到字段或属性。 NONE 表示取消自动映射;PARTIAL
		只会自动映射没有定义嵌套结果集映射的结果集。 FULL 会自动映射任意复杂的结果集(无论是否嵌套)。
		<setting name="autoMappingBehavior" value="PARTIAL" /> -->
		
		<!-- @指定发现自动映射目标未知列(或者未知属性类型)的行为。
		NONE: 不做任何反应
		WARNING: 输出提醒日志
		('org.apache.ibatis.session.AutoMappingUnknownColumnBehavior'的日志等级必须设置为
		WARN)
		FAILING: 映射失败 (抛出 SqlSessionException) 
		<setting name="autoMappingUnknownColumnBehavior" value="WARNING" /> -->
		
		<!-- 配置默认的执行器。SIMPLE 就是普通的执行器;REUSE 执行器会重用预处理语句(prepared statements); BATCH
		执行器将重用语句并执行批量更新。
		<setting name="defaultExecutorType" value="SIMPLE" /> -->
		
		<!-- 设置超时时间,它决定驱动等待数据库响应的秒数。 
		<setting name="defaultStatementTimeout" value="25" /> -->
		
		<!-- 为驱动的结果集获取数量(fetchSize)设置一个提示值。此参数只可以在查询设置中被覆盖
		<setting name="defaultFetchSize" value="100" /> -->
		
		<!-- 允许在嵌套语句中使用分页(RowBounds)。如果允许使用则设置为false 
		<setting name="safeRowBoundsEnabled" value="false" /> -->
		
		<!-- 是否开启自动驼峰命名规则(camel case)映射,即从经典数据库列名 A_COLUMN 到经典 Java 属性名 aColumn
		的类似映射。 
		<setting name="mapUnderscoreToCamelCase" value="false" /> -->
		
		<!-- MyBatis 利用本地缓存机制(Local Cache)防止循环引用(circular references)和加速重复嵌套查询。
		默认值为 SESSION,这种情况下会缓存一个会话中执行的所有查询。 若设置值为 STATEMENT,本地会话仅用在语句执行上,对相同
		SqlSession 的不同调用将不会共享数据。 
		<setting name="localCacheScope" value="SESSION" /> -->
		
		<!-- 当没有为参数提供特定的 JDBC 类型时,为空值指定 JDBC 类型。 某些驱动需要指定列的 JDBC
		类型,多数情况直接用一般类型即可,比如 NULLVARCHAROTHER<setting name="jdbcTypeForNull" value="OTHER" /> -->
		
		<!-- 指定哪个对象的方法触发一次延迟加载。 
		<setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString" /> 
	</settings> -->
</configuration>

配置AssetDaoMapper.xml

代码片.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dao.AssetDao">	
 
 	<!-- 返回的集合 -->
 	<resultMap type="Asset" id="AssetMap">
 		<id property="aid" column="aid" jdbcType="INTEGER"></id>
        <result property="aname" column="uname" jdbcType="VARCHAR"></result>
		<result property="aprice" column="aprice"></result>
 		<result property="adate" column="adate" jdbcType="VARCHAR"></result>
 		<result property="astatu" column="astatu" jdbcType="VARCHAR"></result>
 		<result property="aremark" column="aremark" jdbcType="VARCHAR"></result>
        <association property="type" column="tid" javaType="Type">
        	<result property="tid" column="tid" jdbcType="INTEGER"/>
        	<result property="tgname" column="tgname" jdbcType="VARCHAR"></result>
        	<result property="tlname" column="tlname" jdbcType="VARCHAR"></result>
        </association>
 	</resultMap>
 
	<!-- 按id查询 ,使用连接的方式 --> 
 	<select id="findById" parameterType="int" resultType="AssetMap">
         select * 
         from asset a,type t 
         where a.tid=t.tid and aid=#{aid}
    </select>
 
 	<!-- 全查询,使用连接的方式 -->
	<select id="findAll" resultType="AssetMap">
		 select * 
         from asset a,type t 
         where a.tid=t.tid
	</select>
	
	<!-- 计算总数 -->
	<select id="CountAll" resultType="Integer">
		 select count(*) 
         from asset
	</select>
	
	<!-- 分页查询 -->
	<select id="listOfPage" resultType="Asset">
        select * from asset limit #{currIndex} , #{pageSize}
	</select>

	<!-- 新增 -->
	<insert id="save" parameterType="Asset">
		insert into 
		asset(aname,aprice,adate,astatu,aremark,tid) 
		values (#{u.aname},#{u.aprice},#{u.adate},#{u.astatu},#{u.aremark},#{id})
	</insert>
	
	<!-- 修改 -->
	<update id="update" parameterType="Asset">
		update asset 
		set 
		aname=#{aname},aprice=#{aprice},adate=#{adate},astatu=#{astatu},aremark=#{aremark} 
		where aid=#{aid}
	</update>
 
 	<!-- 删除 -->
	<delete id="delete" parameterType="int">
		delete from asset where aid=#{aid}
	</delete>
</mapper>  

配置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 javax.websocket.server.PathParam;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.service.AssetService;

import entity.Asset;

@Controller
public class AssetAction {
	@Autowired
	private AssetService serivce;

	// 按id查找
	@RequestMapping(value = "AssetfindByid")
	public ModelAndView findByid(@PathParam(value = "id") int id) {
		ModelAndView mav = new ModelAndView();
		mav.addObject("asset", serivce.findById(id));
		mav.setViewName("update_Asset");
		return mav;
	}

	// 查找全部
	@RequestMapping(value = "AssetfindAll")
	public ModelAndView findAll() {
		// 先new一个ModelAndView对象
		ModelAndView mav = new ModelAndView();
		// 以键值队的形式赋值 然后用对象调用方法
		mav.addObject("assets", serivce.findAll());
		// 要跳转的页面
		mav.setViewName("list_Asset");
		// return出来你new的对象
		return mav;
	}

	// 分页查找,n当前页
	public ModelAndView listOfPage(@PathParam(value = "n") int n) {
		int nom=10;
		
		if (n == 0) {
			n = 1;
		}
		
		int s = serivce.CountAll();
		if (s % nom == 0) {
			s = s / nom;
		} else {
			s = s / nom + 1;
		}
		
		// 先new一个ModelAndView对象
		ModelAndView mav = new ModelAndView();	
		mav.addObject("conPage", s);// 设置总页数
		int currIndex =(n-1)*nom;//查询起点
		// 以键值队的形式赋值 然后用对象调用方法
		mav.addObject("assets", serivce.listOfPage(currIndex, 10));//n是请求页,10是一页的数量
		// 要跳转的页面
		mav.setViewName("list_Asset");
		return null;
	}

	// 添加
	@RequestMapping(value = "Assetsave")
	public ModelAndView save(@PathParam(value = "id") int id,Asset u) {
		serivce.save(u,id);
		return new ModelAndView("redirect:/showAsset.do");
	}

	// 修改
	@RequestMapping(value = "Assetupdate")
	public ModelAndView update(Asset u) {
		serivce.update(u);
		return new ModelAndView("redirect:/showAsset.do");
	}

	// 删除
	@RequestMapping(value = "Assetdelete")
	public ModelAndView delete(@PathParam(value = "id") int id) {
		serivce.delete(id);
		return new ModelAndView("redirect:/showAsset.do");
	}
}

Service层:AsserService.java

Service类,代码片.

package com.service;
 
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dao.AssetDao;
import entity.Asset;
 
@Service
public class  AssetService{
	@Autowired
	private AssetDao dao;
 
	public Asset findById(int id) {
		// TODO Auto-generated method stub
		return dao.findById(id);
	}
	
	public List<Asset> findAll() {
		// TODO Auto-generated method stub
		return dao.findAll();
	}
 
	public int CountAll() {
		// TODO Auto-generated method stub
		return dao.CountAll();
	}
	
	public List<Asset> listOfPage(int currIndex,int pageSize) {
		// TODO Auto-generated method stub
		return dao.listOfPage(currIndex, pageSize);
	}
	
	public boolean save(Asset u,int id) {
		// TODO Auto-generated method stub
		int a=dao.save(u,id);
		if(a==1){
			return true;
		}else{
			return false;
		}
	}
 
	public boolean update(Asset u) {
		// TODO Auto-generated method stub
		int a=dao.update(u);
		if(a==1){
			return true;
		}else{
			return false;
		}
	}
	
	public boolean delete(int id) {
		// TODO Auto-generated method stub
		int a=dao.delete(id);
		if(a==1){
			return true;
		}else{
			return false;
		}
	}
}

DAO层:AsserDAO.java

DAO类,代码片.

package com.dao;
 
import java.util.List;

import org.apache.ibatis.annotations.Param;

import entity.Asset;

public interface AssetDao {
	public Asset findById(int id);
	public List<Asset> findAll();
	public int CountAll();
	//多参数传入mapper中使用注解
	public List<Asset> listOfPage(@Param("currIndex") int currIndex,
								  @Param("pageSize")int pageSize);
	public int save(@Param("u")Asset u,@Param("id")int id);
	public int update(Asset u);
	public int delete(int id);
}

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 + "]";
	}	
}

mapper和实体类在一个目录下

总界面.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="TypefindAll.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="AssetfindAll.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="UserfindAll.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="UtilizationfindAll.action">领用信息查询</a></li>
								<hr />
								<li><a href="UtilizationfindAllAsset.action">资产使用管理</a></li>

							</ul></li>
						<li class="drop-down"><a href="#">资产归还</a>
							<hr>
							<ul class="drop-down-content">
								<li><a href="AssetsReturnfindAll.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="ScrapfindAll.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="Assetsave.action" method="post">
	
				资产名称:<input type="text" name="aname"/>
    	<br/>&nbsp;&nbsp;&nbsp;id:<input type="text" name="tid" value="${tid}" readonly="readonly"/>
    	<br/>&nbsp;&nbsp;&nbsp;型:<input type="text" name="type.tgname" disabled="disabled"/>
    	<br/>&nbsp;&nbsp;&nbsp;型:<input type="text" name="type.tlname" disabled="disabled"/>
    	<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.mybatis 映射配置问题。
	2. mybatis 级联操作问题。
	3. 访问路径问题,命名不要使用java保留字,不要用-。
	4. 多看异常,要有信心
**引用包是最大的困难(一步一步来)**
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值