当前位置:网站首页>ssm网页访问数据库数据报错
ssm网页访问数据库数据报错
2022-08-02 10:53:00 【CSDN问答】
今天做ssm数据连接,tomcat服务器启动访问网页都正常,但是跳转网页获取数据库数据的时候就报错了,这是什么问题,是数据库没连接上嘛,还是配置信息缺文件,报错如下

spring配置信息
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<context:component-scan base-package="com.duing.service"/>
<context:property-placeholder location="classpath:druid.properties"/>
<bean id="datasource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/>
bean>
<bean id="factory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="datasource"/> <property name="configLocation" value="classpath:/mybatis.xml"/>
<property name="mapperLocations" value="classpath:mappers/*.xml"/>
bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="factory"/> <property name="basePackage" value="com.duing.dao"/>
bean>
beans>spring配置信息
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<context:component-scan base-package="com.duing.controller"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/>
bean>
<mvc:annotation-driven/> <context:annotation-config/>
beans>mybatis配置信息
configuration PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration> <mappers> <package name="com.duing.dao"/>
mappers>
configuration>mapper配置信息
mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.duing.dao.FilmDao"> <select id="getAll" resultType="com.duing.entity.Film"> select id , film_id,`name`,director,player,`type`,country,`length`,synopsis,play_time,img_path from film
select>
mapper>
mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.duing.dao.UserDao"> <select id="getAll" resultType="com.duing.entity.User"> select `name` , age from user
select>
mapper>controller信息
package com.duing.controller;import com.duing.service.FilmService;import com.duing.vo.FilmVO;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import java.util.List;@Controllerpublic class FilmController { @Autowired private FilmService filmService; @RequestMapping("/filmList") @ResponseBody public List
selectAll(){ List
filmVOS = filmService.selectAll();
return filmVOS; }}
package com.duing.controller;import com.duing.entity.User;import com.duing.service.UserService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import java.util.List;@Controllerpublic class UserController { @Autowired private UserService userService; @RequestMapping("/queryUser") @ResponseBody public List
queryUsers(){
return userService.getAll(); }}
包结构

边栏推荐
- 循环语句综合练习
- After 21 years of graduation, I switched to software testing. From 0 income to a monthly salary of over 10,000, I am really lucky...
- 3D激光slam:LeGO-LOAM---地面点提取方法及代码分析
- 深度学习100例 —— 卷积神经网络(CNN)实现mnist手写数字识别
- 云原生应用平台的核心模块有哪些
- STM32+MPU6050 Design Portable Mini Desktop Clock (Automatically Adjust Time Display Direction)
- 记一次mysql查询慢的优化历程
- 8年软件测试工程师的感悟:与薪资相匹配的永远是实力
- 字节跳动软件测试岗,收到offer后我却拒绝了~给面试的人一些忠告....
- 流动性质押挖矿系统开发如何制作?单双币系统开发成熟技术
猜你喜欢
随机推荐
Event object, do you know it well?
armv7与armv8的区别(v8和w12的区别)
LayaBox---TypeScript---Symbols
3 d laser slam: LeGO - LOAM - ground point extracting method and the analysis of the code
保姆级教程:写出自己的移动应用和小程序(篇二)
Oracle根据时间查询
LayaBox---TypeScript---Module
MP的几种查询方式
Event 对象,你很了解吗?
外包学生管理系统架构文档
鸿星尔克再捐一个亿
一款优秀的中文识别库——ocr
循环语句综合练习
情景剧《重走长征路》上演
【术语科普】关于集成工作台那些难懂的词儿,看这篇秒懂!
LayaBox---TypeScript---装饰器
LayaBox---TypeScript---Decorator
神通数据库,批量插入数据的时候失败
R language ggplot2 visualization: use the ggbarplot function of the ggpubr package to visualize the stacked bar plot, the lab.pos parameter specifies the position of the numerical label of the bar cha
流动性质押挖矿系统开发如何制作?单双币系统开发成熟技术









