自己在搭一个mvc框架,在加入mybatis之后访问页面时错误信息如下:
type Exception report
message Request processing failed; nested exception is java.lang.NullPointerException
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.NullPointerException
zhha.controller.WelcomeController.Welcome(WelcomeController.java:21)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
请问这是什么问题引起的,希望得到一些解决方法的指点。附件为整个框架包。
UserService.java
package zhha.service;
import java.util.List;
import zhha.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import zhha.model.User;
@Service
public class UserService
{
@Autowired
private UserDao userDao;
public List<User> showUser()
{
userDao.select();
List<User> userList = userDao.select();
return userList;
}
}
User.java
package zhha.model;
import java.io.Serializable;
public class User implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String id;
private String name;
private String password;
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getPassword() {
return password;
}
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setPassword(String password) {
this.password = password;
}
}
UserDao.java
package zhha.dao;
import java.util.*;
import zhha.model.User;
public interface UserDao
{
public List<User> select();
}
UserController.java
package zhha.controller;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import zhha.model.User;
import zhha.service.UserService;;
@Controller
@RequestMapping("/")
public class WelcomeController
{
private UserService userService;
@RequestMapping({"/welcome","/"})
public String Welcome()
{
List<User> users = userService.showUser();
System.out.println(users.size());
return "/welcome";
}
@RequestMapping("/hello")
public String Hello()
{
System.out.println("hello--------------------");
return "/hello";
}
}
相关推荐
用idea编写的实现Spring+SpringMVC+Mybatis+Mysql的一个整合,实现了SpringMVC控制访问的页面,将得到的页面参数传递给Spring中的Mybatis的bean类,然后查找Mysql数据的功能,并通过JSP显示出来。纯学习用的。该代码...
这是一个maven工程,整合springMVC和mybits加mysql实现的一个简单的web访问的demo。简单实现的功能是:mysql中有user表,从页面访问,然后springMVC的控制类负责控制跳转,最终执行dao类对应的mybits配置文件中...
主要采用的技术:spring+springMVC+mybatis+Mysql+OSS。该平台采用SSM作为系统的框架支持,系统分为后台管理系统和前台用户系统。后台管理系统主要对用户信息、文件材料、操作日志、审核模块。主要功能包含管理员...
1、spring、springMVC、mybatis整合项目,使用IDEA开发,Tomcat服务器,MySQL数据库。 2、使用interpreter实现登录校验功能,不登录者不能访问相关页面。 3、具备管理员(admin)对图书的增删改查功能和普通用户的...
1)使用 Spring + SpringMVC + MyBatis + Redis + RabbitMQ + Quartz + Bootstrap 进行项目整合开发 2)使用 Redis 实现购物车功能和商品信息的数据缓存功能,提高系统的响应速度并降低数据库的访问压力 3)使用 ...
springmvc-multi-module-project:源码主要为学习整合的SSM框架:SpringMVC + Spring + MyBatis构建maven多模块工程项目,根据不同功能划分模块,方便管理和解压缩。项目主要涉及到的内容有:基于SpringMVC框架(非...
SSM框架:采用经典的Java Web开发框架SSM,将Spring、SpringMVC和MyBatis整合在一起,实现了后端的业务逻辑处理、数据访问和页面展示。 数据库:使用MySQL数据库存储家庭事务管理的相关数据,如家庭成员、任务分配、...
本资源是一个基于SSM(Spring+SpringMVC+MyBatis)框架与MySQL数据库的多角色学生管理系统,前端使用JSP进行页面展示。此项目不仅是一个完整的毕业设计作品,而且包含源代码,为学习和实践SSM框架及多角色权限管理...
1. Spring+SpringMVC+Mybatis框架,实现MVC分层开发。 2. MySQL数据库存储用户信息、照片、相册、评论等数据。 3. Redis用于缓存标签、相册列表、评论列表等信息,减轻数据库压力。 4. Shiro安全框架实现用户认证、...
1. Spring+SpringMVC+Mybatis框架,实现MVC分层开发。 2. MySQL数据库存储文章、评论、分类、标签、用户等数据。 3. Redis用于缓存文章列表、标签列表、分类列表等,减轻数据库压力。 4. Shiro安全框架实现用户认证、...
教材征订管理系统采用Spring、SpringMVC和MyBatis作为主体框架,系统设计遵循界面层、业务逻辑层和数据访问层的Web开发三层架构。采用B/S结构,使得系统更加容易维护。教材征订管理系统主要实现角色有管理员和用户,...
"weixin健身管理系统及会员微信小程序的设计与实现Ssm(源码SSM小程序Vue).zip" 是一个以Spring、SpringMVC和MyBatis(简称SSM)框架为基础,结合微信小程序开发框架Vue.js实现的健身管理系统项目文件压缩包。...
尚硅谷_SpringBoot_数据访问-整合MyBatis(二)-注解版MyBatis 尚硅谷_SpringBoot_数据访问-整合MyBatis(二)-配置版MyBatis 尚硅谷_SpringBoot_数据访问-SpringData JPA简介 尚硅谷_SpringBoot_数据访问-整合JPA ...
尚硅谷_SpringBoot_数据访问-整合MyBatis(二)-配置版MyBatis 尚硅谷_SpringBoot_数据访问-SpringData JPA简介 尚硅谷_SpringBoot_数据访问-整合JPA 尚硅谷_SpringBoot_原理-第一步:创建SpringApplication 尚硅谷_...
spring,springmvc,mybatis(框架) solr(搜索服务),redis(缓存),easyUI(后台系统页面) ### 数据库设计 tb_user用户表(id,username,password,phone,email,created,updated) tb_item商品表(id,title,sell_point,...
65、尚硅谷_SpringBoot_数据访问-整合MyBatis(二)-配置版MyBatis 66、尚硅谷_SpringBoot_数据访问-SpringData JPA简介 67、尚硅谷_SpringBoot_数据访问-整合JPA 68、尚硅谷_SpringBoot_原理-第一步:创建...
整合MyBatis(二)-注解版MyBatis 65、尚硅谷_SpringBoot_数据访问-整合MyBatis(二)-配置版MyBatis 66、尚硅谷_SpringBoot_数据访问-SpringData JPA简介 67、尚硅谷_SpringBoot_数据访问-整合JPA 68、尚硅谷_...
SSM框架:整合了Spring、SpringMVC和MyBatis的Java企业级应用开发框架,用于后端服务的构建。 数据库:可能使用了MySQL或其他关系型数据库来存储数据。 服务器:可能使用了Tomcat等作为Web应用服务器。 功能: ...
6.3 整合Mybatis 122 6.3.1 注解版 123 6.3.2 配置文件版 124 6.4 整合SpringData JPA 125 6.4.1 SpringData简介 125 6.4.2 整合 126 7 Spring Boot启动配置原理 128 7.1 启动流程(Springboot 1.50版本) 128 7.1.1...
65、_SpringBoot_数据访问-整合MyBatis(二)-配置版MyBatis & N+ H8 D$ q1 \4 J+ Y. z 66、_SpringBoot_数据访问-SpringData JPA简介 67、_SpringBoot_数据访问-整合JPA 68、_SpringBoot_原理-第一步:创建...