问题
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