TeamCity: Scripting elements jsp:declaration, jsp:expression, jsp:scriptlet are disallowed here

偶尔善良 提交于 2019-12-23 02:48:17

问题


I am not sure where to begin with this error message. I have tried googling, but I was never able to nail down a solid reason why I am getting this message.

I have looked at various jsp tutorials and they all seem relatively simple so I don't see the problem.

I am writing another plugin for JetBrains TeamCity and have been passing values back and forth between my java code and jsp code with parameters like this:

${parameterName}

Whenever I try to put in real jsp code with tags like

<%= new java.util.Date() %> 

This throws this error.

<%!, <jsp:declaration, <%=, <jsp:expression, <%, <jsp:scriptlet ) are disallowed here

Any help or suggestions are appreciated.


回答1:


Are scriptlets disallowed in the application? Look for <scripting-invalid>true</scripting-invalid> in your web.xml file.

Scriptlets were a mistake. They make it too easy to mingle presentation and logic. So this flag was added to prevent developers from using them in an application and encourage Expression Language and tag libraries instead.




回答2:


You can scripting/scriptlets on and off for different url patterns, so it could be off for .tag files but on for .jsp if necessary. Below is an example, try setting scripting-invalid to false for the file extensions you want to use, maybe that will override the default if JBoss defaults to true:

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <scripting-invalid>true</scripting-invalid>
    </jsp-property-group>
    <jsp-property-group>
        <url-pattern>*.tag</url-pattern>                
        <scripting-invalid>true</scripting-invalid>
    </jsp-property-group>
</jsp-config>



回答3:


I am also facing the same issue. I figured out that the problem occurs when I use scripting tag inside a custom tag. I guess the scripting-invalid or similar things can be defined for a tag too. Just a pointer.




回答4:


If you want to allow the "<%! %>" in the .jsp then:

Step-1: Open web.xml

Step-2: Do the following changes:

<jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <scripting-invalid>false</scripting-invalid>
    </jsp-property-group>
    <jsp-property-group>
        <url-pattern>*.tag</url-pattern>                
        <scripting-invalid>false</scripting-invalid>
    </jsp-property-group>
</jsp-config>

Step-3: Restart the app.

That's all.



来源:https://stackoverflow.com/questions/1423252/teamcity-scripting-elements-jspdeclaration-jspexpression-jspscriptlet-are

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!