編輯:作為對評論的回應,我已經包含了我試圖將 OWASP 庫添加到的 JSP 檔案的起始部分。許多人指出了該宣告:
<%@ taglib prefix="e" uri="https://www.owasp.org/index.php/OWASP_Java_Encoder_Project" %>
該陳述句已經在 J??SP 檔案中。我還在 maven POM 檔案依賴項中添加了所需的 jar。
以下是 JSP 檔案的開頭幾行。如您所見,檔案中已經有多個 taglib 陳述句并且它們已經被使用并且它們已經作業了。我不知道為什么 OWASP taglib 不起作用。任何人都可以提供一個有效的例子嗎?
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="asrs" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="e" uri="https://www.owasp.org/index.php/OWASP_Java_Encoder_Project" %>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" >
<asrs:cssPath relativePath="find.css" />
<asrs:dojoConfig relativePath="lib/dojo/dojo.js" configValue="parseOnLoad: true"/>
<asrs:javascriptPath relativePath="lib/dojo/io/iframe.js"/>
<asrs:javascriptPath relativePath="lib/spring/Spring.js"/>
<asrs:javascriptPath relativePath="lib/spring/Spring-Dojo.js"/>
<asrs:javascriptPath relativePath="Metadata.js"/>
</head>
<body onunload="javascript: exitpop()" onresize="resize()">
<c:if test="${saved}">
<script type="text/javascript" language="JavaScript">
top.close();
</script>
</c:if>
[code continues]
原帖:
我正在嘗試將 OWASP 標記庫添加到使用嵌入式 Tomcat 的 Spring Boot 專案中。此處的專案檔案和此處的其他問題表明這應該是正確的:
<%@ taglib prefix="e" uri="https://www.owasp.org/index.php/OWASP_Java_Encoder_Project" %>
<p>Dynamic data via EL: ${e:forHtml(param.value)}</p>
<p>Dynamic data via tag: <e:forHtml value="${param.value}" /></p>
但我無法讓 Intellij 識別這個標簽庫。我已將兩個 OWASP 依賴項添加到專案中,但似乎沒有任何幫助:
<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder-jsp</artifactId>
<version>1.2.3</version>
</dependency>
這個問題與 OWASP 庫或 Spring Boot 有關嗎?
uj5u.com熱心網友回復:
如果有幫助,請嘗試添加此 Maven 依賴項:
<dependency>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>7.2.0</version>
<type>maven-plugin</type>
</dependency>
然后檢查是否在 pom.xml 中添加了 JSP 檔案所需的依賴項,以便它在 Spring Boot 中作業
在這里瀏覽官方檔案,您已經為 JSP 編碼添加了正確的依賴項,還可以瀏覽 OWASP 提供的 GitHub 上的實作檔案,這里是鏈接
uj5u.com熱心網友回復:
嘗試在 IntelliJ 中使快取無效并重新啟動。
uj5u.com熱心網友回復:
在帶有 EL 的 JSP 中使用
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="e" uri="https://www.owasp.org/index.php/OWASP_Java_Encoder_Project" %>
<html>
<head>
<title>
<b><e:forHtml value="${param.title}" /></b>
</title>
</head>
<body>
<h1>
<b>${e:forHtml(param.data)}</b>
</h1>
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/515248.html
