Mybatis 实现分页使用(四)章节 Error creating document instance.

一、Limit分页使用:

1、编写接口:

分页查询
List getUserBylimit(Map<String,Integer>map);

2、编写mapper.xml 文件

	<resultMap id="UserMap" type="User">
    <result column="pwd" property="password"/>
	</resultMap>

	<!--分页查询 -->
<select id="getUserBylimit" resultType="map" resultMap="UserMap">
        select * from user limit #{startIndex},#{pagSize}
</select>

3、测试跑程序编写

@Test
public void test2(){
SqlSession sqlSession = MybatisUtils.getSQLSession();
UserMapper mapper = sqlSession.getMapper(UserMapper.class);
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put(“startIndex”,0);
map.put(“pagSize”,2);
List userList = mapper.getUserBylimit(map);
for (User user:userList){
System.out.println(user);
}
sqlSession.close();
}

二、报错信息:

Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 7; 不允许有匹配 “[xX][mM][lL]” 的处理指令目标。
在这里插入图片描述

解决办法:

查看xml文件内开头是否有空格,我的正是此问题导致。

MyBatis 分页插件 PageHelper
网址:

https://pagehelper.github.io/docs/howtouse/

根据提供的引用内容,可以看出这是Mybatis框架中的一个错误,具体表现为“nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.”。这个错误通常是由于Mybatis配置文件中存在语法错误或者XML文件格式错误导致的。解决这个问题的方法如下: 1.检查Mybatis配置文件中是否存在语法错误,可以使用XML编辑器或者在线XML验证工具进行检查。 2.检查Mybatis配置文件中是否存在XML文件格式错误,例如标签未闭合、标签嵌套错误等。 3.检查Mybatis配置文件中是否存在非法字符,例如中文字符、特殊符号等。 4.检查Mybatis配置文件中是否存在路径错误,例如文件路径错误、文件名错误等。 5.检查Mybatis配置文件中是否存在重复的配置信息,例如重复的mapper配置等。 下面是一个示例代码,用于演示如何解决这个问题: ```xml <!-- Mybatis配置文件 --> <configuration> <environments default="development"> <environment id="development"> <transactionManager type="JDBC" /> <dataSource type="POOLED"> <property name="driver" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/test" /> <property name="username" value="root" /> <property name="password" value="123456" /> </dataSource> </environment> </environments> <mappers> <mapper resource="com/example/mapper/UserMapper.xml" /> <mapper resource="com/example/mapper/RoleMapper.xml" /> <mapper resource="com/example/mapper/PermissionMapper.xml" /> </mappers> </configuration> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值