发表于: 2017-09-18 23:08:40

1 737


今天完成的事情:

将mybatis与SpringMVC框架结合,不过运行出现错误

明天计划的事情:

使用SpringMVC结合mybatis完成网页——控制器——数据库的数据传递,然后写成restful的风格,使用工具测试其传递的方法


遇到的问题:

1.mybatis和SpringMVC单独可以运行,但是结合运行出现了检测不到bean的错误

   在师兄们的指导下发现是因为web.xml没有写上下文监听器的错误

   解决方法如下:

   在web.xml中加入

<listener>
 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>classpath:spring-mybatis.xml</param-value>
</context-param>

2.上述问题解决后,可以部署到服务器了,但是出现了新的问题

Exception:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Root Cause:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.

未解决,太晚了,明日再战


收获:

1.jsp表单的用法

2.SpringMVC中spring的注入需在web.xml中加入上下文监听器


返回列表 返回列表
评论

    分享到