Servlet & JSP

2017-08-29  本文已影响0人  lllaser

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

解决方法:

<%@ 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时出现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请求

解决方法:

上一篇 下一篇

猜你喜欢

热点阅读