spring controller 方法注解

package com.xiyixi.web.system.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/base")
public class BaseController {
@Autowired
protected HttpServletRequest request;
@Autowired
protected HttpSession session;

@RequestMapping(value="/testget",method = {RequestMethod.GET})
public String testget() {
return "GET";
}
@RequestMapping(value="/testpost",method = {RequestMethod.POST})
public String testgpost() {
return "POST";
}
@RequestMapping(value="/testput",method = {RequestMethod.PUT})
public String testput() {
return "PUT";
}

@RequestMapping(value="/g_and_p",method = {RequestMethod.GET,RequestMethod.POST})
public String testget_post() {
return "GET&POST";
}
}
posted @ 2025-11-04 09:59  zjttiantian  阅读(4)  评论(0)    收藏  举报