找不到Ibatis的配置文件,大侠看看是什么原因,在线等 1,把你的web.xml帖出来看看2,如果懒得帖的话,保证你把sql-map-config.xml 这个文件放在你的工程目录的\WEB-INF\classess这个目录下了,如果还是有问题的话,请参考第一条 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 补充下:3,考虑到即使遵循了第一条的要求,依然有可能看不出来问题在哪里,建议你列出你的WEB-INF\classess下的*.xml文件的名称来4,考虑到即使遵循了第三条的要求,依然有可能看不出来问题在哪里,建议你将xml配置文件中涉及到有加载sql-map-config.xml的地方的配置代码帖出来。 我用Struts+Spring+Ibatis都可以,没问题,我用Junit测试了也通过了,我写了个main()方法测试就是报那错,我的例子流程很简单,就是写了一个Student.xml,在sql-map-config.xml中加载,sql-map-config.xml没有在任何地方加载过,我根本没有和前台搭上关系,我就是用类似于JUNIT测试的方法在main()里面测试,不知道你这句话什么意思:“1,把你的web.xml帖出来看看”这因该和web.xml没关系啊,我就是想得到SqlMapClient对象对数据库进行操作。 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"><sqlMapConfig> <properties resource="com/yumeng/ssidemo/mapping/database.properties" /> <settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true" maxRequests="32" maxSessions="10" maxTransactions="5" useStatementNamespaces="false" /> <transactionManager type="JDBC"> <dataSource type="SIMPLE"> <property value="${driver}" name="JDBC.Driver" /> <property value="${url}" name="JDBC.ConnectionURL" /> <property value="${username}" name="JDBC.Username" /> <property value="${password}" name="JDBC.Password" /> </dataSource> </transactionManager> <sqlMap resource="com/yumeng/ssidemo/po/Student.xml" /></sqlMapConfig> <?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="Student"> <typeAlias alias="student" type="com.yumeng.ssidemo.po.Student"/> <resultMap id="ResultStudent" class="com.yumeng.ssidemo.po.Student" > <result property="id" column="id" columnIndex="1" /> <result property="name" column="name" columnIndex="2" /> <result property="sex" column="sex" columnIndex="3" /> <result property="age" column="age" columnIndex="4" /> <result property="nationality" column="nationality" columnIndex="5" /> <result property="address" column="address" columnIndex="6" /> <result property="phonenumber" column="phonenumber" columnIndex="7" /> </resultMap> <select id="selectStudent" resultMap="ResultStudent"> select * from student </select> <select id="selectStudentById" parameterClass="int" resultClass="Student"> select id ,name,sex,age,nationality,address,phonenumber from student where id = #id# </select> <select id="selectStudentByName" parameterClass="java.lang.String" resultClass="Student"> select * from student where name = #name# </select> <update id="updateStudent" parameterClass="Student"> update student set name =#name#,sex = #sex#,age = #age#, nationality = #nationality#,address = #address#,phonenumber = #phonenumber# where id = #id# </update> <insert id="insertStudent" parameterClass="Student"> insert into student(name,sex,age,nationality,address,phonenumber) values(#name#,#sex#,#age#,#nationality#,#address#,#phonenumber#) </insert> <delete id="deleteStudent" parameterClass="int"> delete from student where id = #id# </delete></sqlMap> 问题是你的sql-map-config.xml是通过哪个配置文件加载的???,配置文件中加载的路径是什么???你的sql-map-config.xml这个文件又放在你服务器的哪个目录下了???这是重点!!!你在main里面测试的是直接给的绝对地址,当然没问题了,这个不是重点! 试试 放到src下,直接写String resource = "sql-map-config.xml "; 请教大家一个问题(JSP) 有没有人知道关于JSF(javaserver faces)好的网站? 求取DOC文件页数方法 HQL语句可以这样写吗? 需要用webservice吗? 【问】JDBC中的错误 在广州找JAVA方面工作 jfreechart的问题 用mysql保存GBK中文時出錯 敢问大虾entity beans 怎么得到另一个entity beans的实体对象,并调用其中的方法? 江湖告急:MyEclipse中配置weblogic9运行时的错误 js如何实现点击 按钮一次增加增加文件域一个
3,考虑到即使遵循了第一条的要求,依然有可能看不出来问题在哪里,建议你列出你的WEB-INF\classess下的*.xml文件的名称来
4,考虑到即使遵循了第三条的要求,依然有可能看不出来问题在哪里,建议你将xml配置文件中涉及到有加载sql-map-config.xml的地方的配置代码帖出来。
中加载,sql-map-config.xml没有在任何地方加载过,我根本没有和前台搭上关系,我就是用类似于JUNIT测试的方法在main()里面测试,不知道你这句话什么意思:“1,把你的web.xml帖出来看看”这因该和web.xml没关系啊,我就是想得到SqlMapClient对象对数据库进行操作。
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd"><sqlMapConfig>
<properties resource="com/yumeng/ssidemo/mapping/database.properties" /> <settings cacheModelsEnabled="true" enhancementEnabled="true"
lazyLoadingEnabled="true" maxRequests="32" maxSessions="10"
maxTransactions="5" useStatementNamespaces="false" /> <transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property value="${driver}" name="JDBC.Driver" />
<property value="${url}" name="JDBC.ConnectionURL" />
<property value="${username}" name="JDBC.Username" />
<property value="${password}" name="JDBC.Password" />
</dataSource>
</transactionManager> <sqlMap resource="com/yumeng/ssidemo/po/Student.xml" /></sqlMapConfig>
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Student">
<typeAlias alias="student" type="com.yumeng.ssidemo.po.Student"/>
<resultMap id="ResultStudent" class="com.yumeng.ssidemo.po.Student" >
<result property="id" column="id" columnIndex="1" />
<result property="name" column="name" columnIndex="2" />
<result property="sex" column="sex" columnIndex="3" />
<result property="age" column="age" columnIndex="4" />
<result property="nationality" column="nationality" columnIndex="5" />
<result property="address" column="address" columnIndex="6" />
<result property="phonenumber" column="phonenumber" columnIndex="7" /> </resultMap>
<select id="selectStudent" resultMap="ResultStudent">
select * from student
</select>
<select id="selectStudentById" parameterClass="int" resultClass="Student">
select id ,name,sex,age,nationality,address,phonenumber
from student where id = #id#
</select>
<select id="selectStudentByName" parameterClass="java.lang.String" resultClass="Student">
select * from student where name = #name#
</select>
<update id="updateStudent" parameterClass="Student">
update student set name =#name#,sex = #sex#,age = #age#,
nationality = #nationality#,address = #address#,phonenumber = #phonenumber#
where id = #id#
</update>
<insert id="insertStudent" parameterClass="Student">
insert into student(name,sex,age,nationality,address,phonenumber)
values(#name#,#sex#,#age#,#nationality#,#address#,#phonenumber#)
</insert>
<delete id="deleteStudent" parameterClass="int">
delete from student where id = #id#
</delete>
</sqlMap>