TeamCity:此处不允许使用脚本元素 jsp:declaration、jsp:expression、jsp:scriptlet

发布于 2024-08-04 22:03:23 字数 479 浏览 5 评论 0原文

我不知道从哪里开始看到这个错误消息。我尝试过谷歌搜索,但我始终无法确定收到此消息的确切原因。

我看过各种jsp教程,它们看起来都比较简单,所以我没有看到问题。

我正在为 JetBrains TeamCity 编写另一个插件,并且一直在我的 java 代码和 jsp 代码之间来回传递值,参数如下:

${parameterName}

每当我尝试使用像这样的标签放入真正的 jsp 代码时,

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

都会抛出此错误。

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

任何帮助或建议表示赞赏。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

拒绝两难 2024-08-11 22:03:23

应用程序中是否不允许使用 scriptlet?在 web.xml 文件中查找 true

Scriptlet 是一个错误。它们使得表达和逻辑很容易混合在一起。因此添加此标志是为了防止开发人员在应用程序中使用它们,并鼓励使用表达式语言和标签库。

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.

王权女流氓 2024-08-11 22:03:23

我也面临着同样的问题。我发现当我在自定义标签内使用脚本标签时会出现问题。我想脚本无效或类似的东西也可以为标签定义。只是一个指针。

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.

农村范ル 2024-08-11 22:03:23

您可以针对不同的 url 模式打开和关闭脚本/scriptlet,因此可以在 .tag 文件中关闭它,但在必要时在 .jsp 中打开它。下面是一个示例,尝试将您要使用的文件扩展名的 scripting-invalid 设置为 false,如果 JBoss 默认为 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>

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>
素罗衫 2024-08-11 22:03:23

如果您想允许 .jsp 中的 "<%! %>",则:

步骤 1:打开 web.xml

步骤 2:执行以下更改:

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

步骤 3:重新启动该应用程序。

就这样。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文