1. springMvc组件与流程

springMVC学习-day01_第1张图片

2.代码编写

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here


    test RequestMapping
    

helloworld
package com.zgz.springmvc.handlers;

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

//标识这个类是一个控制器类
@Controller
public class helloWorld {

    /**
     *  1. 使用@RequestMapping()注解来映射请求的url
     *  2. 返回值会通过视图解析器解析为实际的物理视图, 对于InternalResourceViewResolver 视图解析器会做如下解析: 
     *      通过prefix(前缀) + returnVal + suffix(后缀)的方式得到实际的物理视图
     * @return
     */
    @RequestMapping("/helloworld")
    public String hello() {
        System.out.println("hello world!");
        return "success";
    }
}



    
    
        springDispatcherServlet
        org.springframework.web.servlet.DispatcherServlet
        
        
            contextConfigLocation
            classpath:springmvc.xml
        
        
        1
    

    
        springDispatcherServlet
        /
    



    
    

    
    
        
        
    

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here


    

hello world