最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Spring MVC @GetMapping和@PostMapping注解的使用方式

 更新時(shí)間:2024年05月28日 09:10:52   作者:云淡風(fēng)輕58  
這篇文章主要介紹了Spring MVC @GetMapping和@PostMapping注解的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

創(chuàng)建HelloWorldController

package com.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class HelloWorldController {
	//只接受get方式的請(qǐng)求
	@GetMapping("/testGetMapping")
	public String testGetMapping(Model model) {
		model.addAttribute("msg","測(cè)試@GetMapping注解");
		return "success";
	}
	//只接受post方式的請(qǐng)求
	@PostMapping("/testPostMapping")
	public String testPostMapping(Model model) {
		model.addAttribute("msg","測(cè)試@PostMapping注解");
		return "success";
	}
}

創(chuàng)建index.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>index</title>
</head>
<body>
	<form action="testGetMapping" method="get">
		<button>測(cè)試@GetMapping注解</button>
	</form>
	<br>
	<form action="testPostMapping" method="post">
		<button>測(cè)試@PostMapping注解</button>
	</form>
</body>
</html>

創(chuàng)建success.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>success</title>
</head>
<body>
	${requestScope.msg }
</body>
</html>

啟動(dòng)Tomcat訪問index.jsp

點(diǎn)擊【測(cè)試@GetMapping注解】

點(diǎn)擊【測(cè)試@PostMapping注解】

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

千阳县| 盐城市| 临安市| 鸡西市| 安阳市| 天祝| 太谷县| 桂阳县| 内丘县| 杭锦旗| 清原| 屯留县| 张家港市| 慈溪市| 湾仔区| 辽阳市| 锡林浩特市| 涟水县| 体育| 灌阳县| 若尔盖县| 尼木县| 从江县| 昭苏县| 凭祥市| 宾阳县| 宁都县| 玉龙| 哈巴河县| 洛南县| 凤山县| 无为县| 亚东县| 花垣县| 额敏县| 阿尔山市| 姚安县| 麻城市| 瑞昌市| 平果县| 华阴市|