• springMVC中@requestMapper的使用和注意事项


    package com.hope.controller;

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


    /**
    * @author newcityman
    * @date 2019/11/25 - 22:55
    */
    @Controller("helloController")
    @RequestMapping(path = "/user")
    public class HelloController {
    @RequestMapping(path = "/hello")
    public String sayHello(){
    System.out.println("hello springmvc");
    return "success";
    }

    /**
    * RequestMapping注解
    * @return
    */
    @RequestMapping(path = "/testRequestMapping",method = {RequestMethod.GET}, //path和value有等同效果
    params = {"username=hehe"},headers = {"Accept"})
    public String testRequestMapping(){
    System.out.println("测试RequestMapping");
    return "success";
    }
    }


    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
    <title>入门</title>
    </head>
    <body>
    <h3>入门程序</h3>
    <%--<a href="hello">入门程序</a>--%>

    <a href="user/testRequestMapping?username=hehe">RequestMapping</a>
    </body>
    </html>


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

    <web-app>
    <display-name>Archetype Created Web Application</display-name>

    <servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:springmvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>dispatcherServlet</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>
    </web-app>


    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
    <title>Title</title>
    </head>
    <body>
    <h3>入门成功</h3>
    </body>
    </html>
     
     
     
  • 相关阅读:
    Chip Factory(HDU5536 + 暴力 || 01字典树)
    Xor Sum(HDU4825 + 字典树)
    Happy Matt Friends(HDU5119 + dp)
    Intersection(HDU5120 + 圆交面积)
    [iOS Animation]-CALayer 绘图效率
    [iOS Animation]-CALayer 性能优化
    [iOS Animation]-CALayer 定时器动画
    [iOS Animation]-CALayer 缓冲
    [iOS Animation]CALayer-图层时间
    [iOS Animation]-CALayer 显示动画
  • 原文地址:https://www.cnblogs.com/newcityboy/p/11935009.html
Copyright © 2020-2023  润新知