问题描述
包应该都是对的,我觉得应该是配置的原因,第一次使,求解答错误是:上传附件的内容。靠您了,谢谢<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"><sqlMapConfig> <sqlMap resource="com/ssi/entity/User.xml"/> </sqlMapConfig><?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"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-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"><!-- 通用属性文件定义 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>WEB-INF/jdbc.properties</value> </list> </property> </bean> <!-- connect pool --><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"><property name="driverClassName" value="${jdbc.driverclass}"></property><property name="url" value="${jdbc.url}"></property><property name="username" value="${jdbc.username}"></property><property name="password" value="${jdbc.password}"></property><property name="maxActive" value="100"></property><property name="maxIdle" value="30"></property><property name="maxWait" value="200"></property><property name="defaultAutoCommit" value="true"></property></bean> <!-- IBatis part Spring提供的iBatis的SqlMap配置 --> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation" value="WEB-INF/SqlMapConfig.xml"/> <property name="dataSource" ref="dataSource"/> </bean> <!-- DAO part --><bean id="userDao" class="com.ssi.dao.impl.UserDaoImpl"><property name="sqlMapClient" ref="sqlMapClient"></property></bean><!-- biz part --><bean id="userService" class="com.ssi.service.impl.UserServiceImpl"><property name="userDao" ref="userDao"></property></bean><!-- Action part --><bean id="loginUserAction" class="com.ssi.action.UserAction" scope="prototype"><property name="userService" ref="userService"></property></bean> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="add*" propagation="REQUIRED" /><tx:method name="del*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /><tx:method name="do*" propagation="REQUIRED" /><tx:method name="get*" propagation="REQUIRED" /><tx:method name="find*" propagation="REQUIRED" /><tx:method name="*" propagation="SUPPORTS" read-only="true" /></tx:attributes></tx:advice><aop:config><aop:pointcut id="bizMethods" expression="execution(* com.ssi.service.*.*(..))" /><aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" /></aop:config></beans>这个是User.xml<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"><sqlMap namespace="User"><typeAlias alias="user" type="com.ssi.entity.User" /><select id="CheckLogin" parameterClass="String" resultClass="user"><![CDATA[select password from ssiuser u where u.username = #username#]]></select></sqlMap> 问题补充:解答请看问题补充:当您装好jar包的时候,可以按照以上的配置写法配置。是正确的,但是,其错误的原因是这样的。其主要的问题是出现在了jdbc.properties。正确的应该是:jdbc:oracle:thin:@localhost:1521:root而我的是:jdbc:oracle:thin:@localhost:1521:root就是这个该死的错,也是我马虎的原因,希望大家引以为戒。
解决方案
'<select id="CheckLogin" parameterClass="String" resultClass="user">'中的parameterClass和resultClass这两个属性是iBatis提供的吗?我没有用过,所以看上去这两个属性有疑问。
解决方案二:
java.lang.String写全一下呢?还有就是 那个User.xml的namespace去掉一下的话,加个id呢?
解决方案三:
<select id="CheckLogin" parameterClass="String" resultClass="user"> <![CDATA[select password from ssiuser u where u.username = #username#]]> </select> 去掉 <![CDATA如下:select u.password from ssiuser u where u.username = #username