入门程序之入门代码编写

image.png

HelloController

package com.young.controller;

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

/**
 * 控制器
 */
@Controller
public class HelloController {

    @RequestMapping(path = "/hello")
    public String sayHello() {
        System.out.println("hello SpringMVC");
        return "success";
    }

}

springmvc.xml




    
    

    
    
        
        
    

    
    


success.jsp

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


    Title


    

入门成功

web.xml





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

    
        dispatcherServlet
        /
    


index.jsp

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


    Title


    

入门程序

入门程序

你可能感兴趣的:(入门程序之入门代码编写)