600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 零件库管理信息系统设计--part03:管理员登录部分设计

零件库管理信息系统设计--part03:管理员登录部分设计

时间:2019-08-23 20:12:48

相关推荐

零件库管理信息系统设计--part03:管理员登录部分设计

兄弟们,我又回来啦!

上次我把表建完了。今天来点干货,我们用ssm框架来先简单实现一下管理员的登录功能。

在实现之前,我对user表(管理员表)做了些简单的修改,先来看看:

忽略哪些蓝色的马赛克和乱输的数据,这个表一共5个字段,useraccountnum为账号,其他的都应该能看出来是什么。当然这里还是要说一句,这不是最终的表结构,以后根据需求还会修改的。

那么表有了,开始创建一个动态网页项目,这里我用的eclipse,项目是导的包,包如下:

本来想用maven配置包的,但想到自己对maven用的不熟练,算了,下次用maven做。

建好目录,项目结构如下:

项目名是pls,取得是parts,Library,System三个单词的首字母。服务器用的tomcat9,我觉得挺好用的。比myeclipse自带的服务器不知道快到哪里去了。

首先来看web.xml,代码如下:

1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app xmlns:xsi="/2001/XMLSchema-instance" xmlns="/xml/ns/javaee" xsi:schemaLocation="/xml/ns/javaee /xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> 3 <display-name>pls</display-name> 4 <welcome-file-list> 5<welcome-file>login.html</welcome-file> 6<welcome-file>index.htm</welcome-file> 7<welcome-file>index.jsp</welcome-file> 8<welcome-file>default.html</welcome-file> 9<welcome-file>default.htm</welcome-file>10<welcome-file>default.jsp</welcome-file>11 </welcome-file-list>12 13 <!-- 加载spring容器 -->14<context-param>15 <param-name>contextConfigLocation</param-name>16 <param-value>/WEB-INF/classes/spring/applicationContext.xml,/WEB-INF/classes/spring/applicationContext-*.xml</param-value>17</context-param>18<listener>19 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>20</listener> 212223<!-- 编码过滤器 -->24<filter>25 <filter-name>encodingFilter</filter-name>26 <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>27 <async-supported>true</async-supported>28 <init-param>29 <param-name>encoding</param-name>30 <param-value>UTF-8</param-value>31 </init-param>32</filter>33<filter-mapping>34 <filter-name>encodingFilter</filter-name>35 <url-pattern>/*</url-pattern>36</filter-mapping>3738<!-- Spring监听器 -->39<listener>40 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>41</listener>4243<!-- Spring MVC servlet -->44<servlet>45 <servlet-name>SpringMVC</servlet-name>46 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>47 <init-param>48 <param-name>contextConfigLocation</param-name>49 <param-value>/WEB-INF/classes/spring/springmvc.xml</param-value>50 </init-param>51 <!-- 52 <load-on-startup>1</load-on-startup>53 <async-supported>true</async-supported>54 -->55</servlet>56<servlet-mapping>57 <servlet-name>SpringMVC</servlet-name> 58 <url-pattern>*.action</url-pattern>59</servlet-mapping>60<welcome-file-list>61 <welcome-file>/index.jsp</welcome-file>62</welcome-file-list>63 64 </web-app>

感觉没什么好说的,用处注释都写了,看下一项,config文件夹的目录结构:

一样一样来,先是applicationContext.xml:

1 <beans xmlns="/schema/beans" 2xmlns:xsi="/2001/XMLSchema-instance" xmlns:mvc="/schema/mvc" 3xmlns:context="/schema/context" 4xmlns:aop="/schema/aop" xmlns:tx="/schema/tx" 5xsi:schemaLocation="/schema/beans 6 /schema/beans/spring-beans-3.1.xsd 7 /schema/mvc 8 /schema/mvc/spring-mvc-3.1.xsd 9 /schema/context 10 /schema/context/spring-context-3.1.xsd 11 /schema/aop 12 /schema/aop/spring-aop-3.1.xsd 13 /schema/tx 14 /schema/tx/spring-tx-3.1.xsd ">15 1617<!-- 加载配置文件 -->18<context:property-placeholder location="classpath:db.properties" />19<!-- 使用第三方的数据库连接池dbcp -->20<bean id="dataSource" class="mons.dbcp.BasicDataSource"21 destroy-method="close">22 <property name="driverClassName" value="${jdbc.driver}" />23 <property name="url" value="${jdbc.url}" />24 <property name="username" value="${jdbc.username}" />25 <property name="password" value="${jdbc.password}" />26 <!-- 开发阶段数据库最大连接数建议设置小一点够用即可,设置为3 -->27 <property name="maxActive" value="${jdbc.maxActive}" />28 <property name="maxIdle" value="${jdbc.maxIdle}" />29</bean>3031<!-- 事务管理 -->3233<!-- 事务管理器34mybatis使用jdbc事务管理35-->36<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">37 <!-- 数据源 -->38 <property name="dataSource" ref="dataSource"/>39</bean>4041<!-- 通知 -->42<tx:advice id="txAdvice" transaction-manager="transactionManager">43 <!-- 配置传播行为 -->44 <tx:attributes>45 <tx:method name="save*" propagation="REQUIRED" />46 <tx:method name="insert*" propagation="REQUIRED"/>47 <tx:method name="update*" propagation="REQUIRED"/>48 <tx:method name="delete*" propagation="REQUIRED"/>49 <tx:method name="find*" propagation="SUPPORTS" read-only="true"/>50 <tx:method name="get*" propagation="SUPPORTS" read-only="true"/>51 <tx:method name="select*" propagation="SUPPORTS" read-only="true"/>52 </tx:attributes>53</tx:advice>5455<!-- aop配置 -->56<aop:config>57 <aop:advisor advice-ref="txAdvice"58pointcut="execution(* com.pls.service.imp.*.*(..))"/>59</aop:config>60 61 62 </beans>

然后是applicationContext-dao.xml:

1 <beans xmlns="/schema/beans" 2xmlns:xsi="/2001/XMLSchema-instance" xmlns:mvc="/schema/mvc" 3xmlns:context="/schema/context" 4xmlns:aop="/schema/aop" xmlns:tx="/schema/tx" 5xsi:schemaLocation="/schema/beans 6 /schema/beans/spring-beans-3.1.xsd 7 /schema/mvc 8 /schema/mvc/spring-mvc-3.1.xsd 9 /schema/context 10 /schema/context/spring-context-3.1.xsd 11 /schema/aop 12 /schema/aop/spring-aop-3.1.xsd 13 /schema/tx 14 /schema/tx/spring-tx-3.1.xsd ">15 16 <!-- 配置SqlSessionFactory -->17 <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">18<!-- 数据源 -->19<property name="dataSource" ref="dataSource"/>20<!-- 配置SqlMapConfig.xml -->21<property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml"/>22 </bean>23 24 <!-- 配置userDao -->25 <!-- <bean id="userDao" class="cn.itcast.ssm.dao.old.UserDaoImpl">26注入会话工厂27<property name="sqlSessionFactory" ref="sqlSessionFactoryBean"/>28 </bean> -->29 30 31 <!-- mapper动态代理 -->32 <!-- 配置userMapper33 MapperFactoryBean:用于生成 代理对象34 -->35 <!-- <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">36 注入会话工厂37<property name="sqlSessionFactory" ref="sqlSessionFactoryBean"/>38mapper接口39<property name="mapperInterface" value="cn.itcast.ssm.dao.mapper.UserMapper"/>40 </bean> -->41 42 <!-- 使用mapper批量扫描器扫描mapper接口43 规则:mapper.xml和mapper.java在一个目录 且同名即可 44 扫描出来mapper,自动让spring容器注册,bean的id就是mapper类名(首字母小写)45 -->46 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">47<!-- 会话工厂 -->48<property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBean"/>49 <!-- 扫描包路径 50 多个包中间用半角逗号分隔51 -->52<property name="basePackage" value="com.pls.mapper"/>53 </bean>54 55 56 </beans>

这是以前学的时候用的配置文件,改了改继续拿来用,所以有大量注释掉的代码(我舍不得删.)

applicationContext-service.xml:

1 <beans xmlns="/schema/beans" 2xmlns:xsi="/2001/XMLSchema-instance" xmlns:mvc="/schema/mvc" 3xmlns:context="/schema/context" 4xmlns:aop="/schema/aop" xmlns:tx="/schema/tx" 5xsi:schemaLocation="/schema/beans 6 /schema/beans/spring-beans-3.1.xsd 7 /schema/mvc 8 /schema/mvc/spring-mvc-3.1.xsd 9 /schema/context 10 /schema/context/spring-context-3.1.xsd 11 /schema/aop 12 /schema/aop/spring-aop-3.1.xsd 13 /schema/tx 14 /schema/tx/spring-tx-3.1.xsd ">15 16 17 <!-- 用户管理 -->18 19 <bean id="plsService" class="com.pls.service.imp.PlsServiceImp"/>20 21 </beans>

这里我本来想用注解代替的,但不知怎么的注解没起作用,无法完成注入,有大神的话希望看到后面能为我指出原因。

springmvc-xml:

1 <beans xmlns="/schema/beans" 2xmlns:xsi="/2001/XMLSchema-instance" xmlns:mvc="/schema/mvc" 3xmlns:context="/schema/context" 4xmlns:aop="/schema/aop" xmlns:tx="/schema/tx" 5xsi:schemaLocation="/schema/beans 6 /schema/beans/spring-beans-3.1.xsd 7 /schema/mvc 8 /schema/mvc/spring-mvc-3.1.xsd 9 /schema/context 10 /schema/context/spring-context-3.1.xsd 11 /schema/aop 12 /schema/aop/spring-aop-3.1.xsd 13 /schema/tx 14 /schema/tx/spring-tx-3.1.xsd ">15 16<!-- 组件扫描 只扫描action -->17<context:component-scan base-package="com.pls.controller" />18 19 20<!-- 使用<mvc:annotation-driven />替换上边定义的处理器映射器和适配器 -->21<mvc:annotation-driven />22 23<!-- 视图解析器 解析jsp视图,默认使用jstl,要求classpath下有jstl的jar包 -->24<bean25 class="org.springframework.web.servlet.view.InternalResourceViewResolver">26 <!-- 视图的前缀 -->27 <property name="prefix" value="/WEB-INF/jsp/" />28 <!-- 视图的后缀 -->29 <property name="suffix" value=".jsp" />30 31 32</bean>333435<!--拦截器 -->36<mvc:interceptors>37 38 <mvc:interceptor>39 <mvc:mapping path="/**" />40 <bean class="interceptor.LoginInterceptor"></bean>41 </mvc:interceptor>42 43</mvc:interceptors>4445 46 </beans>

还有:sqlmapconfig.xml:

1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE configuration 3 PUBLIC "-////DTD Config 3.0//EN" 4 "/dtd/mybatis-3-config.dtd"> 5 <configuration> 6 7<!-- 定义别名 --> 8<typeAliases> 9 <package name="com.pls.po" />10</typeAliases>11<!-- 配置mapper映射文件 -->12<mappers>13 <!-- 加载 原始dao使用映射文件 -->14 <!-- <mapper resource="sqlmap/User.xml" /> -->15 16 <!--批量mapper扫描 遵循规则:将mapper.xml和mapper.java文件放在一个目录 且文件名相同 -->17 <!-- <package name="cn.itcast.ssm.dao.mapper" /> -->18</mappers>19 </configuration>

为什么<mappers>内没有代码?回去看dao的xml。

接下来是mapper的目录和po的目录:

这里共有八张表的接口和pojo,今天要涉及到的只有红圈的选中的部分。

这些mapper和pojo不全是自己写的,大部分还是利用mybatis的逆向工程生成的,生成的配置文件如下:

1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE generatorConfiguration 3 PUBLIC "-////DTD MyBatis Generator Configuration 1.0//EN" 4 "/dtd/mybatis-generator-config_1_0.dtd"> 5 6 <generatorConfiguration> 7<context id="testTables" targetRuntime="MyBatis3"> 8 <commentGenerator> 9 <!-- 是否去除自动生成的注释 true:是 : false:否 -->10 <property name="suppressAllComments" value="true" />11 </commentGenerator>12 <!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->13 <jdbcConnection driverClass="com.mysql.jdbc.Driver"14 connectionURL="jdbc:mysql://localhost:3306/partslibrarysystem" userId="root"15 password="20">16 </jdbcConnection>17 <!-- <jdbcConnection driverClass="oracle.jdbc.OracleDriver"18 connectionURL="jdbc:oracle:thin:@127.0.0.1:1521:yycg" 19 userId="yycg"20 password="yycg">21 </jdbcConnection> -->22 23 <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和 24 NUMERIC 类型解析为java.math.BigDecimal -->25 <javaTypeResolver>26 <property name="forceBigDecimals" value="false" />27 </javaTypeResolver>28 29 <!-- targetProject:生成PO类的位置 -->3031 <javaModelGenerator targetPackage="com.pls.po"32 targetProject=".\src">33 34 <!-- enableSubPackages:是否让schema作为包的后缀 -->35 36 <property name="enableSubPackages" value="false" />37 38 <!-- 从数据库返回的值被清理前后的空格 -->39 40 <property name="trimStrings" value="true" />41 </javaModelGenerator>42 43 <!-- targetProject:mapper映射文件生成的位置 -->44 <sqlMapGenerator targetPackage="com.pls.mapper" 45 targetProject=".\src">46 <!-- enableSubPackages:是否让schema作为包的后缀 -->47 <property name="enableSubPackages" value="false" />48 </sqlMapGenerator>49 <!-- targetPackage:mapper接口生成的位置 -->50 <javaClientGenerator type="XMLMAPPER"51 targetPackage="com.pls.mapper" 52 targetProject=".\src">53 <!-- enableSubPackages:是否让schema作为包的后缀 -->54 <property name="enableSubPackages" value="false" />55 </javaClientGenerator>56 <!-- 指定数据库表 -->57 <table schema="" tableName="allsortparts"></table>58 <table schema="" tableName="user"></table>59 <table schema="" tableName="bearing"></table>60 <table schema="" tableName="coupling"></table>61 <table schema="" tableName="electromotor"></table>62 <table schema="" tableName="fastener"></table>63 <table schema="" tableName="flange"></table>64 <table schema="" tableName="sealing_element"></table>65 66 <!-- 有些表的字段需要指定java类型67<table schema="" tableName="">68 <columnOverride column="" javaType="" />69 </table> -->70</context>71 </generatorConfiguration>

还需要这个java类:

1 package gm; 2 3 4 import java.io.File; 5 import java.util.ArrayList; 6 import java.util.List; 7 8 import org.mybatis.generator.api.MyBatisGenerator; 9 import org.mybatis.generator.config.Configuration;10 import org.mybatis.generator.config.xml.ConfigurationParser;11 import org.mybatis.generator.internal.DefaultShellCallback;12 13 public class GeneratorSqlmap {14 15public void generator() throws Exception{16 17 List<String> warnings = new ArrayList<String>();18 boolean overwrite = true;19 //指定逆向工程配置文件。20 File configFile = new File("generatorConfig.xml"); 21 ConfigurationParser cp = new ConfigurationParser(warnings);22 Configuration config = cp.parseConfiguration(configFile);23 DefaultShellCallback callback = new DefaultShellCallback(overwrite);24 MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,25 callback, warnings);26 myBatisGenerator.generate(null);27 28} 29public static void main(String[] args) throws Exception {30 try {31 GeneratorSqlmap generatorSqlmap = new GeneratorSqlmap();32 generatorSqlmap.generator();33 } catch (Exception e) {34 e.printStackTrace();35 }36 37}38 39 }

运行这个文件,mapper和pojo就自动帮你生成了,是不是很方便。

看一看mapper.xml和dao接口吧:

1 package com.pls.mapper; 2 3 import com.pls.po.User; 4 import com.pls.po.UserExample; 5 import java.util.List; 6 import org.apache.ibatis.annotations.Param; 7 8 public interface UserMapper { 9int countByExample(UserExample example);10 11int deleteByExample(UserExample example);12 13int deleteByPrimaryKey(Integer iduser);14 15int insert(User record);16 17int insertSelective(User record);18 19List<User> selectByExample(UserExample example);20 21User selectByPrimaryKey(Integer iduser);22 23int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);24 25int updateByExample(@Param("record") User record, @Param("example") UserExample example);26 27int updateByPrimaryKeySelective(User record);28 29int updateByPrimaryKey(User record);3031User selectByUseraccountnum(String useraccountnum);3233List<User> getAllUser();3435 }

1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE mapper PUBLIC "-////DTD Mapper 3.0//EN" "/dtd/mybatis-3-mapper.dtd" > 3 <mapper namespace="com.pls.mapper.UserMapper" > 4 <resultMap id="BaseResultMap" type="com.pls.po.User" > 5<id column="iduser" property="iduser" jdbcType="INTEGER" /> 6<result column="username" property="username" jdbcType="VARCHAR" /> 7<result column="userpassword" property="userpassword" jdbcType="VARCHAR" /> 8<result column="useraccountnum" property="useraccountnum" jdbcType="VARCHAR" /> 9<result column="useremail" property="useremail" jdbcType="VARCHAR" /> 10 </resultMap> 11 <sql id="Example_Where_Clause" > 12<where > 13 <foreach collection="oredCriteria" item="criteria" separator="or" > 14 <if test="criteria.valid" > 15 <trim prefix="(" suffix=")" prefixOverrides="and" > 16 <foreach collection="criteria.criteria" item="criterion" > 17<choose > 18 <when test="criterion.noValue" > 19 and ${criterion.condition} 20 </when> 21 <when test="criterion.singleValue" > 22 and ${criterion.condition} #{criterion.value} 23 </when> 24 <when test="criterion.betweenValue" > 25 and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 26 </when> 27 <when test="criterion.listValue" > 28 and ${criterion.condition} 29 <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," > 30 #{listItem} 31 </foreach> 32 </when> 33</choose> 34 </foreach> 35 </trim> 36 </if> 37 </foreach> 38</where> 39 </sql> 40 <sql id="Update_By_Example_Where_Clause" > 41<where > 42 <foreach collection="example.oredCriteria" item="criteria" separator="or" > 43 <if test="criteria.valid" > 44 <trim prefix="(" suffix=")" prefixOverrides="and" > 45 <foreach collection="criteria.criteria" item="criterion" > 46<choose > 47 <when test="criterion.noValue" > 48 and ${criterion.condition} 49 </when> 50 <when test="criterion.singleValue" > 51 and ${criterion.condition} #{criterion.value} 52 </when> 53 <when test="criterion.betweenValue" > 54 and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 55 </when> 56 <when test="criterion.listValue" > 57 and ${criterion.condition} 58 <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," > 59 #{listItem} 60 </foreach> 61 </when> 62</choose> 63 </foreach> 64 </trim> 65 </if> 66 </foreach> 67</where> 68 </sql> 69 <sql id="Base_Column_List" > 70iduser, username, userpassword, useraccountnum, useremail 71 </sql> 72 <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.pls.po.UserExample" > 73select 74<if test="distinct" > 75 distinct 76</if> 77<include refid="Base_Column_List" /> 78from user 79<if test="_parameter != null" > 80 <include refid="Example_Where_Clause" /> 81</if> 82<if test="orderByClause != null" > 83 order by ${orderByClause} 84</if> 85 </select> 86 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > 87select 88<include refid="Base_Column_List" /> 89from user 90where iduser = #{iduser,jdbcType=INTEGER} 91 </select> 92 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > 93delete from user 94where iduser = #{iduser,jdbcType=INTEGER} 95 </delete> 96 <delete id="deleteByExample" parameterType="com.pls.po.UserExample" > 97delete from user 98<if test="_parameter != null" > 99 <include refid="Example_Where_Clause" />100</if>101 </delete>102 <insert id="insert" parameterType="com.pls.po.User" >103insert into user (iduser, username, userpassword, 104 useraccountnum, useremail)105values (#{iduser,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{userpassword,jdbcType=VARCHAR}, 106 #{useraccountnum,jdbcType=VARCHAR}, #{useremail,jdbcType=VARCHAR})107 </insert>108 <insert id="insertSelective" parameterType="com.pls.po.User" >109insert into user110<trim prefix="(" suffix=")" suffixOverrides="," >111 <if test="iduser != null" >112 iduser,113 </if>114 <if test="username != null" >115 username,116 </if>117 <if test="userpassword != null" >118 userpassword,119 </if>120 <if test="useraccountnum != null" >121 useraccountnum,122 </if>123 <if test="useremail != null" >124 useremail,125 </if>126</trim>127<trim prefix="values (" suffix=")" suffixOverrides="," >128 <if test="iduser != null" >129 #{iduser,jdbcType=INTEGER},130 </if>131 <if test="username != null" >132 #{username,jdbcType=VARCHAR},133 </if>134 <if test="userpassword != null" >135 #{userpassword,jdbcType=VARCHAR},136 </if>137 <if test="useraccountnum != null" >138 #{useraccountnum,jdbcType=VARCHAR},139 </if>140 <if test="useremail != null" >141 #{useremail,jdbcType=VARCHAR},142 </if>143</trim>144 </insert>145 <select id="countByExample" parameterType="com.pls.po.UserExample" resultType="java.lang.Integer" >146select count(*) from user147<if test="_parameter != null" >148 <include refid="Example_Where_Clause" />149</if>150 </select>151 <update id="updateByExampleSelective" parameterType="map" >152update user153<set >154 <if test="record.iduser != null" >155 iduser = #{record.iduser,jdbcType=INTEGER},156 </if>157 <if test="record.username != null" >158 username = #{record.username,jdbcType=VARCHAR},159 </if>160 <if test="record.userpassword != null" >161 userpassword = #{record.userpassword,jdbcType=VARCHAR},162 </if>163 <if test="record.useraccountnum != null" >164 useraccountnum = #{record.useraccountnum,jdbcType=VARCHAR},165 </if>166 <if test="record.useremail != null" >167 useremail = #{record.useremail,jdbcType=VARCHAR},168 </if>169</set>170<if test="_parameter != null" >171 <include refid="Update_By_Example_Where_Clause" />172</if>173 </update>174 <update id="updateByExample" parameterType="map" >175update user176set iduser = #{record.iduser,jdbcType=INTEGER},177 username = #{record.username,jdbcType=VARCHAR},178 userpassword = #{record.userpassword,jdbcType=VARCHAR},179 useraccountnum = #{record.useraccountnum,jdbcType=VARCHAR},180 useremail = #{record.useremail,jdbcType=VARCHAR}181<if test="_parameter != null" >182 <include refid="Update_By_Example_Where_Clause" />183</if>184 </update>185 <update id="updateByPrimaryKeySelective" parameterType="com.pls.po.User" >186update user187<set >188 <if test="username != null" >189 username = #{username,jdbcType=VARCHAR},190 </if>191 <if test="userpassword != null" >192 userpassword = #{userpassword,jdbcType=VARCHAR},193 </if>194 <if test="useraccountnum != null" >195 useraccountnum = #{useraccountnum,jdbcType=VARCHAR},196 </if>197 <if test="useremail != null" >198 useremail = #{useremail,jdbcType=VARCHAR},199 </if>200</set>201where iduser = #{iduser,jdbcType=INTEGER}202 </update>203 <update id="updateByPrimaryKey" parameterType="com.pls.po.User" >204update user205set username = #{username,jdbcType=VARCHAR},206 userpassword = #{userpassword,jdbcType=VARCHAR},207 useraccountnum = #{useraccountnum,jdbcType=VARCHAR},208 useremail = #{useremail,jdbcType=VARCHAR}209where iduser = #{iduser,jdbcType=INTEGER}210 </update>211 212 <!-- 上面是机器生成的代码,以下是自己写的 -->213 <select id="selectByUseraccountnum" resultMap="BaseResultMap" parameterType="java.lang.String" >214select 215<include refid="Base_Column_List" />216from user217where useraccountnum = #{useraccountnum,jdbcType=VARCHAR}218 </select>219 220 <select id="getAllUser" resultMap="BaseResultMap" >221select * from user222 </select>223 224 225 </mapper>

user.java没什么好说的,但还是贴上来:

1 package com.pls.po; 2 3 public class User { 4private Integer iduser; 5 6private String username; 7 8private String userpassword; 9 10private String useraccountnum;11 12private String useremail;13 14public Integer getIduser() {15 return iduser;16}17 18public void setIduser(Integer iduser) {19 this.iduser = iduser;20}21 22public String getUsername() {23 return username;24}25 26public void setUsername(String username) {27 this.username = username == null ? null : username.trim();28}29 30public String getUserpassword() {31 return userpassword;32}33 34public void setUserpassword(String userpassword) {35 this.userpassword = userpassword == null ? null : userpassword.trim();36}37 38public String getUseraccountnum() {39 return useraccountnum;40}41 42public void setUseraccountnum(String useraccountnum) {43 this.useraccountnum = useraccountnum == null ? null : useraccountnum.trim();44}45 46public String getUseremail() {47 return useremail;48}49 50public void setUseremail(String useremail) {51 this.useremail = useremail == null ? null : useremail.trim();52}53 54@Override55public String toString() {56 return "User [iduser=" + iduser + ", username=" + username + ", userpassword=" + userpassword57 + ", useraccountnum=" + useraccountnum + ", useremail=" + useremail + "]";58}59606162 }

userExample看了下,有点晕:

1 package com.pls.po; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 public class UserExample { 7protected String orderByClause; 8 9protected boolean distinct; 10 11protected List<Criteria> oredCriteria; 12 13public UserExample() { 14 oredCriteria = new ArrayList<Criteria>(); 15} 16 17public void setOrderByClause(String orderByClause) { 18 this.orderByClause = orderByClause; 19} 20 21public String getOrderByClause() { 22 return orderByClause; 23} 24 25public void setDistinct(boolean distinct) { 26 this.distinct = distinct; 27} 28 29public boolean isDistinct() { 30 return distinct; 31} 32 33public List<Criteria> getOredCriteria() { 34 return oredCriteria; 35} 36 37public void or(Criteria criteria) { 38 oredCriteria.add(criteria); 39} 40 41public Criteria or() { 42 Criteria criteria = createCriteriaInternal(); 43 oredCriteria.add(criteria); 44 return criteria; 45} 46 47public Criteria createCriteria() { 48 Criteria criteria = createCriteriaInternal(); 49 if (oredCriteria.size() == 0) { 50 oredCriteria.add(criteria); 51 } 52 return criteria; 53} 54 55protected Criteria createCriteriaInternal() { 56 Criteria criteria = new Criteria(); 57 return criteria; 58} 59 60public void clear() { 61 oredCriteria.clear(); 62 orderByClause = null; 63 distinct = false; 64} 65 66protected abstract static class GeneratedCriteria { 67 protected List<Criterion> criteria; 68 69 protected GeneratedCriteria() { 70 super(); 71 criteria = new ArrayList<Criterion>(); 72 } 73 74 public boolean isValid() { 75 return criteria.size() > 0; 76 } 77 78 public List<Criterion> getAllCriteria() { 79 return criteria; 80 } 81 82 public List<Criterion> getCriteria() { 83 return criteria; 84 } 85 86 protected void addCriterion(String condition) { 87 if (condition == null) { 88 throw new RuntimeException("Value for condition cannot be null"); 89 } 90 criteria.add(new Criterion(condition)); 91 } 92 93 protected void addCriterion(String condition, Object value, String property) { 94 if (value == null) { 95 throw new RuntimeException("Value for " + property + " cannot be null"); 96 } 97 criteria.add(new Criterion(condition, value)); 98 } 99 100 protected void addCriterion(String condition, Object value1, Object value2, String property) {101 if (value1 == null || value2 == null) {102 throw new RuntimeException("Between values for " + property + " cannot be null");103 }104 criteria.add(new Criterion(condition, value1, value2));105 }106 107 public Criteria andIduserIsNull() {108 addCriterion("iduser is null");109 return (Criteria) this;110 }111 112 public Criteria andIduserIsNotNull() {113 addCriterion("iduser is not null");114 return (Criteria) this;115 }116 117 public Criteria andIduserEqualTo(Integer value) {118 addCriterion("iduser =", value, "iduser");119 return (Criteria) this;120 }121 122 public Criteria andIduserNotEqualTo(Integer value) {123 addCriterion("iduser <>", value, "iduser");124 return (Criteria) this;125 }126 127 public Criteria andIduserGreaterThan(Integer value) {128 addCriterion("iduser >", value, "iduser");129 return (Criteria) this;130 }131 132 public Criteria andIduserGreaterThanOrEqualTo(Integer value) {133 addCriterion("iduser >=", value, "iduser");134 return (Criteria) this;135 }136 137 public Criteria andIduserLessThan(Integer value) {138 addCriterion("iduser <", value, "iduser");139 return (Criteria) this;140 }141 142 public Criteria andIduserLessThanOrEqualTo(Integer value) {143 addCriterion("iduser <=", value, "iduser");144 return (Criteria) this;145 }146 147 public Criteria andIduserIn(List<Integer> values) {148 addCriterion("iduser in", values, "iduser");149 return (Criteria) this;150 }151 152 public Criteria andIduserNotIn(List<Integer> values) {153 addCriterion("iduser not in", values, "iduser");154 return (Criteria) this;155 }156 157 public Criteria andIduserBetween(Integer value1, Integer value2) {158 addCriterion("iduser between", value1, value2, "iduser");159 return (Criteria) this;160 }161 162 public Criteria andIduserNotBetween(Integer value1, Integer value2) {163 addCriterion("iduser not between", value1, value2, "iduser");164 return (Criteria) this;165 }166 167 public Criteria andUsernameIsNull() {168 addCriterion("username is null");169 return (Criteria) this;170 }171 172 public Criteria andUsernameIsNotNull() {173 addCriterion("username is not null");174 return (Criteria) this;175 }176 177 public Criteria andUsernameEqualTo(String value) {178 addCriterion("username =", value, "username");179 return (Criteria) this;180 }181 182 public Criteria andUsernameNotEqualTo(String value) {183 addCriterion("username <>", value, "username");184 return (Criteria) this;185 }186 187 public Criteria andUsernameGreaterThan(String value) {188 addCriterion("username >", value, "username");189 return (Criteria) this;190 }191 192 public Criteria andUsernameGreaterThanOrEqualTo(String value) {193 addCriterion("username >=", value, "username");194 return (Criteria) this;195 }196 197 public Criteria andUsernameLessThan(String value) {198 addCriterion("username <", value, "username");199 return (Criteria) this;200 }201 202 public Criteria andUsernameLessThanOrEqualTo(String value) {203 addCriterion("username <=", value, "username");204 return (Criteria) this;205 }206 207 public Criteria andUsernameLike(String value) {208 addCriterion("username like", value, "username");209 return (Criteria) this;210 }211 212 public Criteria andUsernameNotLike(String value) {213 addCriterion("username not like", value, "username");214 return (Criteria) this;215 }216 217 public Criteria andUsernameIn(List<String> values) {218 addCriterion("username in", values, "username");219 return (Criteria) this;220 }221 222 public Criteria andUsernameNotIn(List<String> values) {223 addCriterion("username not in", values, "username");224 return (Criteria) this;225 }226 227 public Criteria andUsernameBetween(String value1, String value2) {228 addCriterion("username between", value1, value2, "username");229 return (Criteria) this;230 }231 232 public Criteria andUsernameNotBetween(String value1, String value2) {233 addCriterion("username not between", value1, value2, "username");234 return (Criteria) this;235 }236 237 public Criteria andUserpasswordIsNull() {238 addCriterion("userpassword is null");239 return (Criteria) this;240 }241 242 public Criteria andUserpasswordIsNotNull() {243 addCriterion("userpassword is not null");244 return (Criteria) this;245 }246 247 public Criteria andUserpasswordEqualTo(String value) {248 addCriterion("userpassword =", value, "userpassword");249 return (Criteria) this;250 }251 252 public Criteria andUserpasswordNotEqualTo(String value) {253 addCriterion("userpassword <>", value, "userpassword");254 return (Criteria) this;255 }256 257 public Criteria andUserpasswordGreaterThan(String value) {258 addCriterion("userpassword >", value, "userpassword");259 return (Criteria) this;260 }261 262 public Criteria andUserpasswordGreaterThanOrEqualTo(String value) {263 addCriterion("userpassword >=", value, "userpassword");264 return (Criteria) this;265 }266 267 public Criteria andUserpasswordLessThan(String value) {268 addCriterion("userpassword <", value, "userpassword");269 return (Criteria) this;270 }271 272 public Criteria andUserpasswordLessThanOrEqualTo(String value) {273 addCriterion("userpassword <=", value, "userpassword");274 return (Criteria) this;275 }276 277 public Criteria andUserpasswordLike(String value) {278 addCriterion("userpassword like", value, "userpassword");279 return (Criteria) this;280 }281 282 public Criteria andUserpasswordNotLike(String value) {283 addCriterion("userpassword not like", value, "userpassword");284 return (Criteria) this;285 }286 287 public Criteria andUserpasswordIn(List<String> values) {288 addCriterion("userpassword in", values, "userpassword");289 return (Criteria) this;290 }291 292 public Criteria andUserpasswordNotIn(List<String> values) {293 addCriterion("userpassword not in", values, "userpassword");294 return (Criteria) this;295 }296 297 public Criteria andUserpasswordBetween(String value1, String value2) {298 addCriterion("userpassword between", value1, value2, "userpassword");299 return (Criteria) this;300 }301 302 public Criteria andUserpasswordNotBetween(String value1, String value2) {303 addCriterion("userpassword not between", value1, value2, "userpassword");304 return (Criteria) this;305 }306 307 public Criteria andUseraccountnumIsNull() {308 addCriterion("useraccountnum is null");309 return (Criteria) this;310 }311 312 public Criteria andUseraccountnumIsNotNull() {313 addCriterion("useraccountnum is not null");314 return (Criteria) this;315 }316 317 public Criteria andUseraccountnumEqualTo(String value) {318 addCriterion("useraccountnum =", value, "useraccountnum");319 return (Criteria) this;320 }321 322 public Criteria andUseraccountnumNotEqualTo(String value) {323 addCriterion("useraccountnum <>", value, "useraccountnum");324 return (Criteria) this;325 }326 327 public Criteria andUseraccountnumGreaterThan(String value) {328 addCriterion("useraccountnum >", value, "useraccountnum");329 return (Criteria) this;330 }331 332 public Criteria andUseraccountnumGreaterThanOrEqualTo(String value) {333 addCriterion("useraccountnum >=", value, "useraccountnum");334 return (Criteria) this;335 }336 337 public Criteria andUseraccountnumLessThan(String value) {338 addCriterion("useraccountnum <", value, "useraccountnum");339 return (Criteria) this;340 }341 342 public Criteria andUseraccountnumLessThanOrEqualTo(String value) {343 addCriterion("useraccountnum <=", value, "useraccountnum");344 return (Criteria) this;345 }346 347 public Criteria andUseraccountnumLike(String value) {348 addCriterion("useraccountnum like", value, "useraccountnum");349 return (Criteria) this;350 }351 352 public Criteria andUseraccountnumNotLike(String value) {353 addCriterion("useraccountnum not like", value, "useraccountnum");354 return (Criteria) this;355 }356 357 public Criteria andUseraccountnumIn(List<String> values) {358 addCriterion("useraccountnum in", values, "useraccountnum");359 return (Criteria) this;360 }361 362 public Criteria andUseraccountnumNotIn(List<String> values) {363 addCriterion("useraccountnum not in", values, "useraccountnum");364 return (Criteria) this;365 }366 367 public Criteria andUseraccountnumBetween(String value1, String value2) {368 addCriterion("useraccountnum between", value1, value2, "useraccountnum");369 return (Criteria) this;370 }371 372 public Criteria andUseraccountnumNotBetween(String value1, String value2) {373 addCriterion("useraccountnum not between", value1, value2, "useraccountnum");374 return (Criteria) this;375 }376 377 public Criteria andUseremailIsNull() {378 addCriterion("useremail is null");379 return (Criteria) this;380 }381 382 public Criteria andUseremailIsNotNull() {383 addCriterion("useremail is not null");384 return (Criteria) this;385 }386 387 public Criteria andUseremailEqualTo(String value) {388 addCriterion("useremail =", value, "useremail");389 return (Criteria) this;390 }391 392 public Criteria andUseremailNotEqualTo(String value) {393 addCriterion("useremail <>", value, "useremail");394 return (Criteria) this;395 }396 397 public Criteria andUseremailGreaterThan(String value) {398 addCriterion("useremail >", value, "useremail");399 return (Criteria) this;400 }401 402 public Criteria andUseremailGreaterThanOrEqualTo(String value) {403 addCriterion("useremail >=", value, "useremail");404 return (Criteria) this;405 }406 407 public Criteria andUseremailLessThan(String value) {408 addCriterion("useremail <", value, "useremail");409 return (Criteria) this;410 }411 412 public Criteria andUseremailLessThanOrEqualTo(String value) {413 addCriterion("useremail <=", value, "useremail");414 return (Criteria) this;415 }416 417 public Criteria andUseremailLike(String value) {418 addCriterion("useremail like", value, "useremail");419 return (Criteria) this;420 }421 422 public Criteria andUseremailNotLike(String value) {423 addCriterion("useremail not like", value, "useremail");424 return (Criteria) this;425 }426 427 public Criteria andUseremailIn(List<String> values) {428 addCriterion("useremail in", values, "useremail");429 return (Criteria) this;430 }431 432 public Criteria andUseremailNotIn(List<String> values) {433 addCriterion("useremail not in", values, "useremail");434 return (Criteria) this;435 }436 437 public Criteria andUseremailBetween(String value1, String value2) {438 addCriterion("useremail between", value1, value2, "useremail");439 return (Criteria) this;440 }441 442 public Criteria andUseremailNotBetween(String value1, String value2) {443 addCriterion("useremail not between", value1, value2, "useremail");444 return (Criteria) this;445 }446}447 448public static class Criteria extends GeneratedCriteria {449 450 protected Criteria() {451 super();452 }453}454 455public static class Criterion {456 private String condition;457 458 private Object value;459 460 private Object secondValue;461 462 private boolean noValue;463 464 private boolean singleValue;465 466 private boolean betweenValue;467 468 private boolean listValue;469 470 private String typeHandler;471 472 public String getCondition() {473 return condition;474 }475 476 public Object getValue() {477 return value;478 }479 480 public Object getSecondValue() {481 return secondValue;482 }483 484 public boolean isNoValue() {485 return noValue;486 }487 488 public boolean isSingleValue() {489 return singleValue;490 }491 492 public boolean isBetweenValue() {493 return betweenValue;494 }495 496 public boolean isListValue() {497 return listValue;498 }499 500 public String getTypeHandler() {501 return typeHandler;502 }503 504 protected Criterion(String condition) {505 super();506 this.condition = condition;507 this.typeHandler = null;508 this.noValue = true;509 }510 511 protected Criterion(String condition, Object value, String typeHandler) {512 super();513 this.condition = condition;514 this.value = value;515 this.typeHandler = typeHandler;516 if (value instanceof List<?>) {517 this.listValue = true;518 } else {519 this.singleValue = true;520 }521 }522 523 protected Criterion(String condition, Object value) {524 this(condition, value, null);525 }526 527 protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {528 super();529 this.condition = condition;530 this.value = value;531 this.secondValue = secondValue;532 this.typeHandler = typeHandler;533 this.betweenValue = true;534 }535 536 protected Criterion(String condition, Object value, Object secondValue) {537 this(condition, value, secondValue, null);538 }539}540 }

service接口就不看了,直接看实现类代码:

1 package com.pls.service.imp; 2 3 import java.util.List; 4 5 import javax.annotation.Resource; 6 7 import org.springframework.stereotype.Service; 8 9 import com.pls.mapper.UserMapper;10 import com.pls.po.User;11 import com.pls.po.UserExample;12 import com.pls.po.UserExample.Criteria;13 import com.pls.service.PlsService;14 15 @Service("plsService")16 public class PlsServiceImp implements PlsService {17 18@Resource19private UserMapper userDao;22@Override23public User getUserById(int iduser) {24 // TODO Auto-generated method stub25 return this.userDao.selectByPrimaryKey(iduser);26}2728@Override29public List<User> getAllUser() {30 // TODO Auto-generated method stub31 //List<User> list;32 3334 //UserExample e=new UserExample();35 36 List<User> list=this.userDao.getAllUser();37 38 return list;39}40 41//根据用户名查找用户,主要用于登录时验证密码42@Override43public User getUserByUseraccountnum(String useraccountnum){44 45 //UserExample example= new UserExample();46 //Criteria criteria=example.createCriteria();47 //criteria.andUseraccountnumEqualTo(useraccountnum);48 User user=this.userDao.selectByUseraccountnum(useraccountnum);49 50 51 52 return user;53}5455//删除方法56@Override57public void deleteUser(int iduser){58 this.userDao.deleteByPrimaryKey(iduser);59}6061//根据名字或账号查询方法62@Override63public List<User> findByNameOrAccountnum(String nameOrAccountnum){64 UserExample e1=new UserExample();65 Criteria c1=e1.createCriteria();66 c1.andUsernameLike("%"+nameOrAccountnum+"%");67 List<User> list=this.userDao.selectByExample(e1);68 UserExample e2=new UserExample();69 Criteria c2=e2.createCriteria();70 c2.andUseraccountnumLike("%"+nameOrAccountnum+"%");71 list.addAll(this.userDao.selectByExample(e2));72 return list;73}7475//插入的方法76@Override77public int insertUser(User user){78 79 int iduser=this.userDao.insert(user);80 81 return iduser;82}8384//更新用户85@Override86public int updateUser(User User){87 88 int iduser=this.userDao.updateByPrimaryKey(User);89 90 return iduser;91 92}93 }

控制层目录:

先看userController:

1 package com.pls.controller; 2 3 import javax.servlet.http.HttpServletRequest; 4 5 import org.springframework.context.ApplicationContext; 6 import org.springframework.context.support.ClassPathXmlApplicationContext; 7 import org.springframework.stereotype.Controller; 8 import org.springframework.ui.Model; 9 import org.springframework.web.bind.annotation.RequestMapping;10 11 import com.pls.po.User;12 import com.pls.service.PlsService;13 14 @Controller15 @RequestMapping("/log")16 public class UserController {17 18ApplicationContext ac = new ClassPathXmlApplicationContext(new String[] { "spring/applicationContext.xml",19 "spring/applicationContext-dao.xml", "spring/applicationContext-service.xml" });20PlsService plsService = (PlsService) ac.getBean("plsService");21 22//用于验证用户密码是否输入正确23@RequestMapping("/submit")24public String toIndex(HttpServletRequest request, Model model, String useraccountnum, String password) {25 26 27 User user = this.plsService.getUserByUseraccountnum(useraccountnum);28 if (user != null) {29 if (user.getUserpassword().equals(password)) {30 31 model.addAttribute("user", user);32 model.addAttribute("iduser", user.getIduser());33 return "index";34 35 } else {36 return "error";37 }38 } else {39 return "error";40 }41 42}43 44//跳转到登录页面45@RequestMapping("/login")46public String login(Model model) throws Exception {47 48 return "login";49}505152 }

本来想用注解直接注入service的,结果一直报空指针错误,注入不成功,没办法只好用导配置文件的方式,不知道哪位大神能给我指点一下,说一下那个地方出错了。

这里我就不按action一个一个给你们看jsp页面及实现效果了,现在已经快12点了,我待会儿集中放后面。

manageController:

1 package com.pls.controller; 2 3 import java.util.List; 4 5 import javax.servlet.http.HttpServletRequest; 6 7 import org.springframework.context.ApplicationContext; 8 import org.springframework.context.support.ClassPathXmlApplicationContext; 9 import org.springframework.stereotype.Controller; 10 import org.springframework.ui.Model; 11 import org.springframework.web.bind.annotation.PathVariable; 12 import org.springframework.web.bind.annotation.RequestMapping; 13 import org.springframework.web.bind.annotation.RequestMethod; 14 15 import com.pls.po.User; 16 import com.pls.service.PlsService; 17 18 @Controller 19 @RequestMapping("/manage") 20 public class MannageController { 21 22ApplicationContext ac = new ClassPathXmlApplicationContext(new String[] { "spring/applicationContext.xml", 23 "spring/applicationContext-dao.xml", "spring/applicationContext-service.xml" }); 24PlsService plsService = (PlsService) ac.getBean("plsService"); 25 26@RequestMapping("/showUser") 27public String showUser(Model model) throws Exception { 28 29 List<User> list = this.plsService.getAllUser(); 30 model.addAttribute("list", list); 31 32 return "showUser"; 33} 34 35@RequestMapping(value = "/deleteUser/{iduser}", method = RequestMethod.GET) 36public String deleteUser(HttpServletRequest request, Model model, @PathVariable int iduser) throws Exception { 37 38 this.plsService.deleteUser(iduser); 39 List<User> list = this.plsService.getAllUser(); 40 model.addAttribute("list", list); 41 42 return "showUser"; 43} 44 45@RequestMapping("/findUser") 46public String findUser(HttpServletRequest request, Model model, String nameOrAccountnum) throws Exception { 47 48 // this.plsService.findByNameOrAccountnum(nameOrAccountnum); 49 List<User> list = this.plsService.findByNameOrAccountnum(nameOrAccountnum); 50 model.addAttribute("list", list); 51 52 return "showUser"; 53} 54 55// 跳转到填加管理员页面 56@RequestMapping("/addManage") 57public String addManage(Model model) throws Exception { 58 59 return "addManage"; 60} 61 62// 添加管理员 63@RequestMapping("/submitUser") 64public String submitUser(HttpServletRequest request, Model model, String accountnum, String userpassword, 65 String username, String Email) throws Exception { 66 67 User user = new User(); 68 user.setUseraccountnum(accountnum); 69 user.setUseremail(Email); 70 user.setUsername(username); 71 user.setUserpassword(userpassword); 72 73 int iduser = this.plsService.insertUser(user); 74 75 if (iduser > 0) { 76 77 List<User> list = this.plsService.getAllUser(); 78 model.addAttribute("list", list); 79 80 return "showUser"; 81 } 82 83 return "addUserError"; 84} 85 86// 修改管理员 87@RequestMapping(value = "/updateUser/{iduser}", method = RequestMethod.GET) 88public String updateUser(HttpServletRequest request, Model model, @PathVariable int iduser) throws Exception { 89 90 User user = this.plsService.getUserById(iduser); 91 model.addAttribute("user", user); 92 93 return "updateManage"; 94} 95 96// 提交修改的管理员 97@RequestMapping("/updateUserSubmit") 98public String updateSubmitUser(HttpServletRequest request, Model model, String accountnum, String userpassword, 99 String username, String Email, int iduser) throws Exception {100 101 User user = new User();102 user.setUseraccountnum(accountnum);103 user.setUseremail(Email);104 user.setUsername(username);105 user.setUserpassword(userpassword);106 user.setIduser(iduser);107 108 if (this.plsService.updateUser(user) > 0) {109 110 List<User> list = this.plsService.getAllUser();111 model.addAttribute("list", list);112 113 return "showUser";114 }115 return null;116}117 118 }

webContent目录:

jsp页面代码,依次序排列:

1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"> 4 <html> 5 <head> 6<title></title> 7<meta charset="UTF-8"> 8<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/html/Css/bootstrap.css" /> 9<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/html/Css/bootstrap-responsive.css" />10<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/html/Css/style.css" />11<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/jquery2.js"></script>12<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/jquery2.sorted.js"></script>13<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/bootstrap.js"></script>14<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/ckform.js"></script>15<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/common.js"></script>16<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/jquerypicture.js"></script>1718<style type="text/css">19 body {font-size: 20px;20 padding-bottom: 40px;21 background-color:#e9e7ef;22 }23 .sidebar-nav {24 padding: 9px 0;25 }26 27 @media (max-width: 980px) {28 /* Enable use of floated navbar text */29 .navbar-text.pull-right {30 float: none;31 padding-left: 5px;32 padding-right: 5px;33 }34 }35 36 37</style>38 </head>39 <body>40 <br>41 <font color="#777777"><strong>请填写管理员资料:</strong></font>42 <form action="${pageContext.request.contextPath }/manage/submitUser.action" method="post" class="definewidth m20" >43 <table class="table table-bordered table-hover m10" style="margin-left:10px;margin-top:3px;">4445 46 <br>47<tr>48 <td class="tableleft">账号</td>49 <td><input type="text" name="accountnum" /></td>50 <td class="tableleft">密码</td>51 <td><input type="text" name="userpassword" /></td>52</tr>53<tr>54 <td class="tableleft">姓名</td>55 <td><input type="text" name="username" /></td>56 <td class="tableleft">邮箱</td>57 <td><input type="text" name="Email" /></td>58</tr>596061 </table>62 <br>63 &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<button type="submit" onclick="${pageContext.request.contextPath }/manage/submitUser.action" class="btn btn-primary">提交</button>64 </form>65 <img src="" id="img0" > 66 67 <script> 68 $("#GoodsPicture").change(function(){69var objUrl = getObjectURL(this.files[0]) ;70console.log("objUrl = "+objUrl) ;71if (objUrl) {72 $("#img0").attr("src", objUrl) ;73}74 }) ;75 76 </body>77 </html>78 <script>79 $(function (){ 80 $('#backid').click(function(){81 window.location.href="goodsQuery.html";82});83});84 85 </script>

1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"> 4 <html lang="zh"> 5 <head> 6 <meta charset="UTF-8"> 7 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 8 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 9 <title>插入用户错误错误</title>10 11 12 13 14 15 </head>16 <body>17 18 19 <h1>插入用户错误错误</h1>20 21 22 </body>23 </html>

1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"> 4 <html lang="zh"> 5 <head> 6 <meta charset="UTF-8"> 7 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 8 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 9 <title>错误</title>10 11 12 13 14 15 </head>16 <body>17 18 19 <h1>不存在的用户或用户名密码错误</h1>20 21 22 </body>23 </html>

1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"> 4 5 <html> 6 <head> 7 <meta charset="utf-8"> 8 <title>零件库管理系统</title> 9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 10 <link href="../html/Css/adminStyle.css" rel="stylesheet" type="text/css" /> 11 12 <title>零件库管理系统</title> 13 <script type="text/javascript" src="../html/js/jquery1.js"></script> 14 <script type="text/javascript"> 15$(document).ready( 16 function() { 17 $(".div2").click( 18function() { 19 $(this).next("div").slideToggle("slow").siblings( 20 ".div3:visible").slideUp("slow"); 21}); 22 }); 23function openurl(url) { 24 var rframe = parent.document.getElementById("rightFrame"); 25 rframe.src = url; 26} 27 </script> 28 <style> 29 body {30margin: 0; 31font-family: 微软雅黑; 32background-image: url(images/.jpg); 33background-repeat: no-repea; 34background-size: cover; 35background-attachment: fixed; 36background-color: #DDDDDD 3738 } 39 40 .top1 {41position: absolute; 42top: 0px; 43width: 100%; 44height: 20px; 45text-align: center; 46color: #FFFFFF; 47font-size: 17px; 48font-height: 20px; 49font-family: 楷体; 50background-color: #888888 51 } 52 53 .title {54 float:left; 55margin:-32px 20px; 56font-size: 40px; 57color: #FFFFFF; 58font-height: 55px; 59font-family: 隶书; 60 } 61 62 .top2 {63position: absolute; 64top: 20px; 65width: 100%; 66height: 77px; 67text-align: center; 68color: #ccffff; 69background-color: #888888 70 } 71 72 .left {73position: absolute; 74left: 0px; 75top: 97px; 76width: 200px; 77height: 85%; 78border-right: 1px solid #9370DB; 79color: #000000; 80font-size: 20px; 81text-align: center; 82background-color: #B3B3B3 83 } 84 85 .right {86position: absolute; 87left: 200px; 88top:97px; 89width: 85.2%; 90height: 85%; 91border-top: 0px solid #484860; 92font-size: 14px; 93text-align: center; 94 } 95 96 .end {97position: absolute; 98bottom: 0px; 99width: 100%;100height: 30px;101text-align: center;102color: #556B2F;103font-size: 17px;104font-height: 20px;105font-family: 楷体;106background-color: #C0C0C0107 }108 109 .div1 {110text-align: center;111width: 200px;112padding-top: 10px;113 }114 115 .div2 {116height: 40px;117line-height: 40px;118cursor: pointer;119font-size: 18px;120position: relative;121border-bottom: #ccc 0px dotted;122 }123 124 .spgl {125position: absolute;126height: 20px;127width: 20px;128left: 40px;129top: 10px;130background: url(images/1.png);131 }132 133 .yhgl {134position: absolute;135height: 20px;136width: 20px;137left: 40px;138top: 10px;139background: url(images/4.png);140 }141 142 .gggl {143position: absolute;144height: 20px;145width: 20px;146left: 40px;147top: 10px;148background: url(images/4.png);149 }150 151 .zlgl {152position: absolute;153height: 20px;154width: 20px;155left: 40px;156top: 10px;157background: url(images/4.png);158 }159 160 .pjgl {161position: absolute;162height: 20px;163width: 20px;164left: 40px;165top: 10px;166background: url(images/4.png);167 }168 169 .tcht {170position: absolute;171height: 20px;172width: 20px;173left: 40px;174top: 10px;175background: url(images/2.png);176 }177 178 .div3 {179display: none;180cursor: pointer;181font-size: 15px;182 }183 184 .div3 ul {185margin: 0;186padding: 0;187 }188 189 .div3 li {190height: 30px;191line-height: 30px;192list-style: none;193border-bottom: #ccc 1px dotted;194text-align: center;195 }196 197 .a {198text-decoration: none;199color: #000000;200font-size: 15px;201 }202 203 .a1 {204text-decoration: none;205color: #000000;206font-size: 18px;207 }208 </style>209 </head>210 <body>211 212<div class="top1">213 <marquee scrollAmount=2 width=300>数据无价,请谨慎操作!</marquee>214</div>215<div class="top2">216 <div class="logo">217 <img src="../html/images/admin_logo.png" title="在哪儿" />218 </div>219 <div class="title" >220 <h3>零件库管理系统</h3>221 </div>222 <div class="fr top-link">223 <a href="admin_list.html" target="mainCont" title="DeathGhost"><i224 class="adminIcon"></i><span>管理员:${user.username }</span></a> 225 </div>226</div>227 228<div class="left">229 <div class="div1">230 <div class="left_top">231 <img src="../html/images/bbb_01.jpg"><img src="../html/images/bbb_02.jpg"232 id="2"><img src="../html/images/bbb_03.jpg"><img233 src="../html/images/bbb_04.jpg">234 </div>235 236 <div class="div2">237 <div class="spgl"></div>238 视频管理239 </div>240 <div class="div3">241 <li><a class="a" href="javascript:void(0);"242 onClick="openurl('videoQuery.html');">查看所有视频</a></li>243 <li><a class="a" href="javascript:void(0);"244 onClick="openurl('uservideoQuery.html');">用户视频列表</a></li>245246 </div>247 <div class="div2">248 <div class="spgl"></div>249 文档管理250 </div>251 <div class="div3">252 <ul>253 <li><a class="a" href="javascript:void(0);"254onClick="openurl('documentQuery.html');">查看所有文档</a></li>255<li><a class="a" href="javascript:void(0);"256onClick="openurl('userdocumentQuery.html');">用户文档列表</a></li>257 258 </ul>259 </div>260 <div class="div2">261 <div class="spgl"></div>262 类别管理263 </div>264 <div class="div3">265 <ul>266 <li><a class="a" href="javascript:void(0);"267onClick="openurl('classQuery.html');">大类信息</a></li>268269 </ul>270 </div>271 <div class="div2">272 <div class="yhgl"></div>273 用户管理274 </div>275 <div class="div3">276 <ul>277 <li><a class="a" href="javascript:void(0);"278onClick="openurl('studentQuery.html');">学生管理</a></li>279 <li><a class="a" href="javascript:void(0);"280onClick="openurl('${pageContext.request.contextPath }/manage/showUser.action');">老师管理</a></li>281 </ul>282 </div>283 284 <div class="div2">285 <div class="gggl"></div>286 评价管理287 </div>288 <div class="div3">289 290 <ul>291 <li><a class="a" href="javascript:void(0);"292onClick="openurl('deletecomment.html');">评价删除</a></li>293 <li><a class="a" href="javascript:void(0);"294onClick="openurl('useredit.html');">用户禁言</a></li>295 </ul>296 297 </div>298 <div class="div2">299 <div class="pjgl"></div>300 公告管理301 </div>302 <div class="div3">303 <ul>304 <li><a class="a" href="javascript:void(0);"305onClick="openurl('afficheQuery.html');">查看公告</a></li>306 <li><a class="a" href="javascript:void(0);"307onClick="openurl('afficheAdd.html');">添加公告</a></li>308 </ul>309 </div>310 <a class="a1" href="login.html"><div class="div2">311 <div class="tcht"></div>312 退出后台313 </div></a>314 </div>315</div>316 317<div class="right">318 <iframe id="rightFrame" name="rightFrame" width="100%" height="100%"319 scrolling="auto" marginheight="0" marginwidth="0" align="center"320 style="border: 0px solid #CCC; margin: 0; padding: 0;"></iframe>321</div>322 323 324 325 326 327 328 329 </body>330 </html>

1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"> 4 <html lang="zh"> 5 <head> 6 <meta charset="UTF-8"> 7 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 8 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 9 <title>零件库管理系统登录界面</title>10 11 <link rel="stylesheet" type="text/css" href="../html/Css/styles.css">12 13 14 15 </head>16 <body>17 18 19 <div class="wrapper">20 21<div class="container">22 <h1>零件库管理系统</h1>23 <form class="form" action="${pageContext.request.contextPath }/log/submit.action" method="post">24 <input type="text" placeholder="Username" name="useraccountnum">25 <input type="password" placeholder="Password" name="password"><br>26 <button type="submit" id="login-button" onclick="${pageContext.request.contextPath }/log/submit.action"><strong>登陆</strong></button>27 28 </form>29</div>3031<ul class="bg-bubbles">32 <li></li>33 <li></li>34 35</ul>3637 </div>38 39 40 41 </body>42 </html>

1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2pageEncoding="UTF-8"%> 3 <%@ taglib uri="/jsp/jstl/fmt" prefix="fmt"%> 4 <%@ taglib uri="/jsp/jstl/core" prefix="c"%> 5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"> 6 <html> 7 <head> 8 <title></title> 9 <meta charset="UTF-8">10 <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/html/Css/bootstrap.css" />11 <link rel="stylesheet" type="text/css"12href="<%=request.getContextPath() %>/html/Css/bootstrap-responsive.css" />13 <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/html/Css/style.css" />14 <script type="text/javascript" src="<%=request.getContextPath() %>/html/js/jquery2.js"></script>15 <script type="text/javascript" src="<%=request.getContextPath() %>/html/js/jquery2.sorted.js"></script>16 <script type="text/javascript" src="<%=request.getContextPath() %>/html/js/bootstrap.js"></script>17 <script type="text/javascript" src="<%=request.getContextPath() %>/html/js/ckform.js"></script>18 <script type="text/javascript" src="<%=request.getContextPath() %>/html/js/common.js"></script>19 20 <style type="text/css">21 body {22font-size: 20px;23padding-bottom: 40px;24background-color: #e9e7ef;25 }26 27 .sidebar-nav {28padding: 9px 0;29 }30 31 @media ( max-width : 980px) {32/* Enable use of floated navbar text */33.navbar-text.pull-right {34 float: none;35 padding-left: 5px;36 padding-right: 5px;37}38 }39 </style>40 </head>41 <body>42<form class="form-inline definewidth m20" action="${pageContext.request.contextPath }/manage/findUser.action" method="post">43 <font color="#777777"><strong>管理员姓名或账号:</strong></font> <input44 type="text" name="nameOrAccountnum" id="menuname" class="abc input-default"45 placeholder="" value="">&nbsp;&nbsp;46 <button type="submit" class="btn btn-primary">查询</button>47 <button type="button" id="addnew">48 <a href="${pageContext.request.contextPath }/manage/addManage.action">添加管理员</a>49 </button>50</form>51<table class="table table-bordered table-hover definewidth m10">52 <thead>53 <tr>54 <th>管理员姓名</th>55 56 <th>管理员账号</th>57 58 <th>Email</th>59 <th>注销账户</th>60 <th>修改用户</th>61 </tr>62 </thead>63 <c:forEach items="${list}" var="manage">64 <tr>65 <!-- <a href="teacherdetail.html">nblyp</a> -->66 <td>${manage.username }</td>67 68 <td>${manage.useraccountnum }</td>69 <td>${manage.useremail }</td>70 <!-- 71 <td><button type="submit" οnclick="${pageContext.request.contextPath }/manage/deleteUser/${manage.iduser }.action" method="get">注销</button></td>72 -->73 <td><a href="${pageContext.request.contextPath }/manage/deleteUser/${manage.iduser }.action">注销</a></td>74 <td><a href="${pageContext.request.contextPath }/manage/updateUser/${manage.iduser }.action">修改</a></td>75 </tr>76 </c:forEach>7778 79</table>80 81 </body>82 </html>

1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"> 4 <html> 5 <head> 6<title></title> 7<meta charset="UTF-8"> 8<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/html/Css/bootstrap.css" /> 9<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/html/Css/bootstrap-responsive.css" />10<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/html/Css/style.css" />11<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/jquery2.js"></script>12<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/jquery2.sorted.js"></script>13<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/bootstrap.js"></script>14<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/ckform.js"></script>15<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/common.js"></script>16<script type="text/javascript" src="<%=request.getContextPath() %>/html/js/jquerypicture.js"></script>1718<style type="text/css">19 body {font-size: 20px;20 padding-bottom: 40px;21 background-color:#e9e7ef;22 }23 .sidebar-nav {24 padding: 9px 0;25 }26 27 @media (max-width: 980px) {28 /* Enable use of floated navbar text */29 .navbar-text.pull-right {30 float: none;31 padding-left: 5px;32 padding-right: 5px;33 }34 }35 36 37</style>38 </head>39 <body>40 <br>41 <font color="#777777"><strong>请填写管理员资料:</strong></font>42 <form action="${pageContext.request.contextPath }/manage/updateUserSubmit.action" method="post" class="definewidth m20" >43 <table class="table table-bordered table-hover m10" style="margin-left:10px;margin-top:3px;">4445 46 <br>47<tr>4849 <td class="tableleft">账号</td>50 <td><input type="text" name="accountnum" value=${user.useraccountnum} /></td>51 <td class="tableleft">密码</td>52 <td><input type="text" name="userpassword" value=${user.userpassword} /></td>53</tr>54<tr>55 <td class="tableleft">真实姓名</td>56 <td><input type="text" name="username" value=${user.username} /></td>57 <td class="tableleft">邮箱</td>58 <td><input type="text" name="Email" value=${user.useremail} /></td>59</tr>60<input type="hidden" name="iduser" value=${user.iduser} />6162 </table>63 <br>64 &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<button type="submit" onclick="${pageContext.request.contextPath }/manage/updateUserSubmit.action" class="btn btn-primary">提交</button>65 </form>66 <img src="" id="img0" > 67 68 <script> 69 $("#GoodsPicture").change(function(){70var objUrl = getObjectURL(this.files[0]) ;71console.log("objUrl = "+objUrl) ;72if (objUrl) {73 $("#img0").attr("src", objUrl) ;74}75 }) ;76 77 </body>78 </html>79 <script>80 $(function (){ 81 $('#backid').click(function(){82 window.location.href="goodsQuery.html";83});84});85 86 </script>

代码是糙了一点,不过因为是第一次做项目嘛,包容包容。

来看看最后效果:

这肯定不是最终版本,我还有一些功能及一些地方需要修改。前端的代码不是我自己写的,是从网上下载的免费模板,在此感谢源码之家提供的免费模板,有兴趣的小伙伴可以取下一个来玩。本人第一次做项目,发到博客来和大家探讨学习,希望那些大神嘴下留情,不喜勿喷。

我还会继续更新我的毕设的,感谢大家支持。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。