path & basePath
<%
// 當前頁面
String path = request.getContextPath();
// 項目根目錄
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
head中加入<base href="...">
標簽用來表明當前頁面的相對路徑所使用的根路徑河狐。
<head>
<base href="<%= basePath %>">
</head>
JSTL
jstl標簽不起作用慌植,報錯The tag handler class for "c:if" (org.apache.taglibs.standard.tag.rt.core.IfTag) was not found on the Java Build Path
解決方法:
- 在jsp頁面開頭加上jstl的taglib
- 在page標簽中加上屬性
isELIgnored="false"
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isELIgnored="false" %>
SpringMVC REST風格使用DELETE和PUT METHOD時出現(xiàn)HTTP Status 405 – Method Not Allowed
HTTP Status 405 – Method Not Allowed
Type Status Report
Message JSPs only permit GET POST or HEAD
Description The method received in the request-line is known by the origin server but not supported by the target resource.
Apache Tomcat/9.0.0.M22
原因:JSP 2.3只支持GET POST HEAD請求
解決方法:
- 簡單解決方法蝶柿,在被請求的頁面
<%@ page %>
中添加<%@ page isErrorPage="true" %>
- 詳細信息參看 stackoverflow - HTTP Status 405 - JSPs only permit GET POST or HEAD