SpringMVC

三层架构

SpringMVC_第1张图片

SpringMVC_第2张图片

 SpringMVC_第3张图片入门案例

目录结构SpringMVC_第4张图片

 pom.xml




  4.0.0

  cn.itcast
  springmvc_day01_01
  1.0-SNAPSHOT
  war

  springmvc_day01_01 Maven Webapp
  
  http://www.example.com

  
    UTF-8
    1.8
    1.8
    5.0.2.RELEASE
  

  
    
      org.springframework
      spring-context
      ${spring.version}
    
    
      org.springframework
      spring-web
      ${spring.version}
    
    
      org.springframework
      spring-webmvc
      ${spring.version}
    
    
      javax.servlet
      servlet-api
      2.5
      provided
    
    
      javax.servlet.jsp
      jsp-api
      2.0
      provided
    
  

  
    springmvc_day01_01
    
      
        
          maven-clean-plugin
          3.1.0
        
        
        
          maven-resources-plugin
          3.0.2
        
        
          maven-compiler-plugin
          3.8.0
        
        
          maven-surefire-plugin
          2.22.1
        
        
          maven-war-plugin
          3.2.2
        
        
          maven-install-plugin
          2.5.2
        
        
          maven-deploy-plugin
          2.8.2
        
      
    
  

 springmvc.xml



       
        
        
        
        
        
        
                
                
        

controller类

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package cn.itcast.controller;

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

@Controller
public class HelloController {
    public HelloController() {
    }

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

    @RequestMapping(
        path = {"/testRequestMapping"}
    )
    public String testRequestMapping() {
        System.out.println("testing RequestMapping_zhujie...");
        return "success";
    }
}

web.xml




  Archetype Created Web Application
  
    dispatcherServlet
    org.springframework.web.servlet.DispatcherServlet
    
      contextConfigLocation
      classpath*:springmvc.xml
    
    1
  
  
    dispatcherServlet
    /
  
  
 /Index1.jsp


 Index1.jsp

<%--
  Created by IntelliJ IDEA.
  User: 17860
  Date: 2023/4/3
  Time: 22:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    Title


入门程序

<%--入门程序--%> RequestMapping_zhujie

success.jsp

<%--
  Created by IntelliJ IDEA.
  User: 17860
  Date: 2023/4/3
  Time: 22:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    Title


入门成功

你可能感兴趣的:(java,servlet,maven)