解决方案 »
- ssh整合问题,部署一次要删除一次asm-2-2-3.jar包??有没有解决方法
- JSP、servlet与Spring之间有什么关系?
- 关于设置目录的问题??
- 图书馆图书入库管理
- 求问个spring配置数据源的错误
- 关于"test".equals(param)与param.equals("test")的探讨
- 建一个企业网站要多少内存啊
- 开始学JSP
- 点击form提交按钮后,是否可以先执行数据库更新,再调用一个java程序?
- 求教tomcat目录配置
- Spring MVC bean空值跪求高手指点啊!
- 我按照网上说的步骤,进入官网下载了spring包,但是,找了好久,没找到依赖包,它藏在哪里呀?大家能帮我找找吗,求具体步骤?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:p="http://www.springframework.org/schema/p"
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/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- 引入JDBC配置文件 -->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:oracle.properties"></property>
</bean>
<bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name="driverClassName" value="${jdbc.driver}"></property>
</bean>
<!-- myBatis文件 创建SqlSessionFactory,同时指定数据源 -->
<bean id="sqlsessionfactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="datasource"></property>
<property name="mapperLocations" value="classpath*:com/cn/mapper/**/*.xml"></property>
<property name="typeAliasesPackage" value="com.anwin.model"></property>
</bean>
<!--DAO map-->
<bean id="userdao" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.cn.mapper.UserDao" />
<property name="sqlSessionFactory" ref="sqlsessionfactory" />
</bean>
<?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">
<configuration>
<typeAliases>
<typeAlias type="com.anwin.model.News_User" alias="user"/>
</typeAliases><mapper namespace="com.cn.mapper.UserDao">
<cache></cache>
<!-- 注册用户 -->
<insert id="regiest" parameterType="user">
<selectKey keyProperty="id" order="BEFORE" resultType="int"
statementType="STATEMENT">
SELECT NVL(MAX(ID),0)+1 FROM NEWS_USER
</selectKey>
INSERT INTO NEWS_USER (id,usercode,name,password,email,address)
VALUES(#{id},#{usercode},#{name},#{password},#{email},#{address,jdbcType=VARCHAR})
</insert>
<!-- 修改用户信息 -->
<update id="update" parameterType="user">
UPDATE NEWS_USER
<trim prefix="set" suffixOverrides=",">
<if test="usercode!=null and usercode!=0">
usercode=#{usercode},
</if>
<if test="name!=null and name!=''">
name=#{name},
</if>
<if test="password!=null and password!=''">
password=#{password},
</if>
<if test="email!=null and email!=''">
email=#{email},
</if>
<if test="address!=null and address!=''">
address=#{address},
</if>
</trim>
WHERE id=#{id}
</update>
<!-- 两种验证的sql -->
<sql id="verify_sql">
SELECT COUNT(*) FROM NEWS_USER
<trim prefix="where" prefixOverrides="and">
<if test="id!=null and id!=0">
and id=#{id}
</if>
<if test="email!=null and email!=''">
and email=#{email}
</if>
<if test="password!=null and password!=''">
and password=#{password}
</if>
</trim>
</sql>
<!-- 邮箱登陆 -->
<select id="email_Login" parameterType="user" resultType="int">
<include refid="verify_sql" />
</select>
<!-- id登陆 -->
<select id="id_Login" parameterType="user" resultType="int">
<include refid="verify_sql" />
</select>
<!-- 查找所有用户 -->
<resultMap type="user" id="resultmap">
<id property="id" column="id" />
<result property="usercode" column="usercode" />
<result property="name" column="name" />
<result property="password" column="password" />
<result property="email" column="email" />
<result property="address" column="address" />
</resultMap>
<select id="select" resultMap="resultmap">
SELECT * FROM
NEWS_USER
</select>
</mapper>
</configuration>