package com.kkb.controller;
import com.kkb.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class UsersController {
@Autowired
UsersService usersService;
@RequestMapping("hello.do")
public ModelAndView add(){
System.out.println("UserController-----add");
usersService.add();
ModelAndView mv = new ModelAndView();
mv.addObject("UserName","湖人");//相当于request.setAttrobuite("UserName","湖人");
mv.setViewName("index"); //未来经过SpringMVC的视图解析器处理,转换成物理路径,相当于request.getRequestDispatcher("index.jsp").forward();
//经过InternalResourceViewResolver对象的处理之后加上前后缀就变为了/jsp/index.jsp
return mv;
}
}
service层
package com.kkb.service;
import org.springframework.stereotype.Service;
@Service
public class UsersService {
public void add(){
System.out.println("UsersService-------add");
}
}
3.6 配置视图解析器
在springmvc.xml配置文件中添加视图解析器的配置
3.7 编写index.jsp页面
<%--
Created by IntelliJ IDEA.
User: zhao
Date: 2021/4/22
Time: 17:14
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
Title
index------------${UserName}
3.8 测试
3.9 解析
当 Spring 和 SpringMVC 同时出现,我们的项目中将存在两个容器,一个是 Spring 容器,另一个是 SpringMVC 容器,Spring 容器通过 ContextLoaderListener 来加载,SpringMVC 容器则通过 DispatcherServlet 来加载,这两个容器不一样:
在使用Eclipse进行开发的时候,出现了如下的问题:
Description Resource Path Location TypeThe project was not built due to "A resource exists with a different case: '/SeenTaoImp_zhV2/bin/seentao'.&
var grid = $('#datagrid');
var options = grid.datagrid('getPager').data("pagination").options;
var curr = options.pageNumber;
var total = options.total;
var max =