我在web.xml中禁用了所有JSP中的脚本:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
</jsp-property-group>
</jsp-config>但是,我需要导入一些自定义的tagLibs,它们是这样使用的:
<%@ taglib prefix="utils" uri="/tags-utils" %>如何在不使用scriptlet的情况下导入它?此外,如何避免使用以下内容?
<%@ page language="java" contentType="text/html; charset=UTF-8" %>删除scriptlet的决定是避免由多个开发人员编写的项目中的scriptlet混乱。
如果在不使用scriptlet的情况下无法更改导入,那么我将如何禁用它以供<%@ taglib或<%@ page以外的任何使用
试图改变
<%@ taglib prefix="s" uri="/struts-tags" %>至
<jsp:directive.tagLib prefix="s" uri="struts-tags" />但是Servlet抛出了一个错误:
org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/portal].[jsp] Servlet.service() for servlet jsp抛出异常: org.apache.jasper.JasperException: /index.jsp(2,18)
我还有别的事要做吗?
发布于 2013-05-08 02:08:55
JSP2.2规范
JSP句法的EBNF语法
ScriptlessBody ::= ( ( ‘<%--’ JSPCommentBody )
| ( ‘<%@’ DirectiveBody )
| ( ‘<jsp:directive.’ XMLDirectiveBody )
| ( ‘<%!’ <TRANSLATION_ERROR> )
| ( ‘<jsp:declaration’ <TRANSLATION_ERROR> )
| ( ‘<%=’ <TRANSLATION_ERROR> )
| ( ‘<jsp:expression’ <TRANSLATION_ERROR> )
| ( ‘<%’ <TRANSLATION_ERROR> )
| ( ‘<jsp:scriptlet’ <TRANSLATION_ERROR> )
| ( ‘${‘ ELExpressionBody )
| ( ‘#{‘ ELExpressionBody )
| ( ‘<jsp:text’ XMLTemplateText )
| ( ‘<jsp:’ StandardAction )
( ( ‘</’ ExtraClosingTag )
| ( ‘<‘ CustomAction CustomActionBody )
| TemplateText
)*所以,当scripting-invalid=true
非法
<%
<%!
<%=
<jsp:scriptlet
<jsp:declaration
<jsp:expressionLegal
<%@
<jsp:directive.
<jsp:以下是合法的:
<%@ taglib prefix="utils" uri="/tags-utils" %>只要"app context uri“+”/tags utils“(taglib的上下文-相对路径)映射到"taglib绝对uri”。
或者,您可以尝试::
<%@ taglib prefix="utils" uri="http://www.mycorp/utiltags" %> // use your absolute taglib URI或
<%@ taglib prefix="utils" uri="uri_path_relative_to_jsp_uri" %> // no leading "/"或
<%@ taglib prefix="utils" tagdir="/WEB-INF/tags" %> // include subdir if approp以下是发明的。没有定义jsp:directive.tagLib 标记。不要用.
<jsp:directive.tagLib prefix="s" uri="struts-tags" />而不是:
<%@ page language="java" contentType="text/html; charset=UTF-8" %>Try:
<%@ page contentType="text/html; charset=UTF-8" %> // language is for scriptlets发布于 2012-12-08 18:49:25
<%@taglib和<%@page是指令,而不是脚本。
Scriptlet将拥有<%。
或者你也可以这样写
<jsp:directive.taglib uri="uri" prefix="prefixOfTag" />https://stackoverflow.com/questions/13780661
复制相似问题