Servlet & JSP

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

解决方法:

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容