标签:enc style bind public import 方式 control return hand
可以使用method指定请求的方式:
package com.gong.springmvc.handlers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @RequestMapping("/springmvc") @Controller public class SpringmvcTest { private static final String SUCCESS = "success"; @RequestMapping(value="testMethod",method=RequestMethod.POST) public String testMethod() { 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> <form action="springmvc/testMethod" method="POST"> <input type="submit" value="submit"/> </form> </body> </html>
springmvc之RequestMapping中的请求方式
标签:enc style bind public import 方式 control return hand
原文地址:https://www.cnblogs.com/xiximayou/p/12176207.html