Spring Boot用浏览器关闭程序

来源:互联网 发布:淘宝网豆豆鞋 编辑:程序博客网 时间:2024/06/05 03:53

application.properties

#启动url shutdownendpoints.shutdown.enabled=true


index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'index.jsp' starting page</title>    <meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">-->  </head>    <body>     hello jsp          <form action="${pageContext.request.contextPath}/shutdown" method="post">        <input type="submit" value="关闭"/>     </form>       </body></html>

在浏览器中访问jsp

http://localhost/sb/index.jsp


如果直接访问http://localhost/sb/shutdown会出现请求限定的错误,因为用浏览器直接跳转只能是GET

那这个Action只能用POST请求访问才会生效,所以利用form表单跳转来关闭程序

原创粉丝点击