springmvc入门

2021-03-27 06:25

阅读:726

YPE web->

标签:content   versions   request   color   bsp   Servle   framework   src   bin   

一、文件结构

技术图片

 

 二、pom.xml

"1.0" encoding="UTF-8"?>

"http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    4.0.0org.example
    A03springmvc
    1.0-SNAPSHOTwarA03springmvc Maven Webapphttp://www.example.comUTF-81.81.85.2.8.RELEASEorg.springframework
            spring-context
            ${spring.version}org.springframework
            spring-web
            ${spring.version}org.springframework
            spring-webmvc
            ${spring.version}javax.servlet
            servlet-api
            2.5providedjavax.servlet.jsp
            jsp-api
            2.0providedA03springmvc
                    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

三、web.xml

span>app PUBLIC
        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd" >

Archetype Created Web ApplicationdispatcherServletclass>org.springframework.web.servlet.DispatcherServletclass>
        contextConfigLocationclasspath:springmvc.xml1dispatcherServlet/

四、springmvc的xml配置文件

"1.0" encoding="UTF-8"?>
"http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        https://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        https://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    
    base-package="com.wuxi">"internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        "prefix" value="/WEB-INF/pages/">"suffix" value=".jsp">

五、controller类

package com.wuxi.controllers;

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

@Controller
public class HelloController {
    @RequestMapping("/hello")
    public String hello() {
        return "success";
    }
}

六、页面

  index页面

"text/html;charset=UTF-8" language="java" %>


Hello World!

"hello">跳转到成功页面

  其他页面

"text/html;charset=UTF-8" language="java" %>Title
成功页面

 

springmvc入门

标签:content   versions   request   color   bsp   Servle   framework   src   bin   

原文地址:https://www.cnblogs.com/linding/p/13671621.html


评论


亲,登录后才可以留言!