zoukankan      html  css  js  c++  java
  • springmvc之RequestMapping注解既可以修饰类也可以修饰方法

    @RequestMapping不仅可以修饰类,也可以修饰方法。

    总而言之,用@RequestMapping标识的是请求的URL地址。例如:

    package com.gong.springmvc.handlers;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    @RequestMapping("/springmvc")
    @Controller
    public class SpringmvcTest {
        private static final String SUCCESS = "success";
        @RequestMapping("/test")
        public String test() {
            System.out.println("RequestmMapping");
            return SUCCESS;
        }
    }

    此时在jsp中访问就需要这么访问请求:

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
        <a href="springmvc/test">springmvc test</a>
    </body>
    </html>
  • 相关阅读:
    linux下的watch命令
    Erlang运行时的错误
    Redis查看帮助文档
    PO Box简介
    用erlang写的kmp算法
    laravel全过程
    artdialog 弹出框
    支持触屏版的旋转幻灯片
    android生成APP的名字,图标,开机动画
    使用Eclipse构建app网站应用
  • 原文地址:https://www.cnblogs.com/xiximayou/p/12176169.html
Copyright © 2011-2022 走看看