Java – how to correctly escape triple nested quotation marks in JSP Tags

We have just upgraded Tomcat. The newer Tomcat does not like to nest quotation marks in tags, so we must alternate between single quotation marks and double quotation marks For example,

We did,

<form id="search" action="<fmt:message key="search.url"/>">

Now we can change it to,

<form id="search" action="<fmt:message key='search.url'/>">

What if the quotation is so triple nested?

<form id="search" action="<fmt:message key='<c:out value="${requestScope.search_url}"/>'/>">

The above tags cannot be compiled

Solution

If you do not want to update all jsp: s for Tomcat upgrade only, set the system property "org. Apache. Jasper. Compiler. Parser. Strict_quote_escaping" to false

The easiest way is to edit Catalina SH and add the following to Java_ In opts:

-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>