当前位置:网站首页>ssm web page access database data error
ssm web page access database data error
2022-08-02 11:00:00 【CSDN Q&A】
今天做ssm数据连接,tomcatThe server starts to access the web pages normally,But when I jump to the web page to get the database data, I get an error,这是什么问题,The database is not connected,The configuration file is still missing,报错如下
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(); }}
包结构
边栏推荐
猜你喜欢
FPGA手撕代码——CRC校验码的多种Verilog实现方式 (2021乐鑫科技数字IC提前批代码编程)
零代码工具推荐---HiFlow
开箱即用-使用异步加载布局来优化页面启动速度的几种方案
MySQL百万数据优化总结 一
365天挑战LeetCode1000题——Day 047 设计循环队列 循环队列
Why use BGP?
深度学习100例 —— 卷积神经网络(CNN)实现mnist手写数字识别
Failed to configure mysql, what's going on?
Outsourced Student Management System Architecture Documentation
如何在技术上来保证LED显示屏质量?
随机推荐
21 Days Learning Challenge - Day 1 Punch (Screen Density)
MSYS2 QtCreator Clangd 代码分析找不到 mm_malloc.h的问题补救
Geoffery Hinton: The Next Big Thing in Deep Learning
超赞!发现一个APP逆向神器!
你好,我的新名字叫“铜锁/Tongsuo”
LayaBox---TypeScript---命名空间和模块
The sitcom "Re-Walking the Long March" was staged
SQLAlchemy使用教程
LayaBox - TypeScript - merge statement
3D激光slam:LeGO-LOAM---地面点提取方法及代码分析
Hello, my new name is "Bronze Lock/Tongsuo"
云原生应用平台的核心模块有哪些
How to choose a truly "easy-to-use, high-performance" remote control software
深度学习100例 —— 卷积神经网络(CNN)实现mnist手写数字识别
Deep Learning 100 Examples - Convolutional Neural Network (CNN) for mnist handwritten digit recognition
ssm网页访问数据库数据报错
LeetCode每日一练 —— 225. 用队列实现栈
有奖征集|TaoCloud&宝德联合举办全闪POC!
38岁女儿不恋爱没有稳定工作老母亲愁哭
全方位剖析Numpy中的np.diag源代码