springmvc纯xml配置映射1,零注解

package com.study.web;

import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.ResponseBody;

import org.springframework.web.servlet.ModelAndView;

import org.springframework.web.servlet.mvc.AbstractController;

import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class LoginController implements Controller {

@Override

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)throws Exception {

               ModelAndView mv=new ModelAndView("index.jsp");

    return mv;

}

}


package com.study.intercepters;

import org.springframework.web.servlet.HandlerInterceptor;

import org.springframework.web.servlet.ModelAndView;

import org.springframework.web.servlet.handler.MappedInterceptor;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class MyIntercepter1implements HandlerInterceptor {

@Override

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)throws Exception {

System.out.println("===pre===");

//        return false;

        return  true;

}

@Override

    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)throws Exception {

System.out.println("===post===");

}

@Override

    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)throws Exception {

System.out.println("===afterCompletion===");

}

}


Archetype Created Web Application

org.springframework.web.context.ContextLoaderListener

 

contextConfigLocation

classpath:spring-web.xml

springmvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:springmvc.xml

1

springmvc

*.do



      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xmlns:p="http://www.springframework.org/schema/p"

      xmlns:context="http://www.springframework.org/schema/context"

      xmlns:mvc="http://www.springframework.org/schema/mvc"

      xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context.xsd

http://www.springframework.org/schema/mvc

        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

       


            注入方式2:mappings

                <!– /hello 路径的请求交给 id 为 helloController 的控制器处理–>

loginController

-->

   

你可能感兴趣的:(springmvc纯xml配置映射1,零注解)