将 XML 解析器更改为 Xerces 时出现 JSP 编译错误

发布于 2024-08-29 14:23:46 字数 1281 浏览 9 评论 0原文

全部, 我正在开发一个 Java Web 应用程序,我们将其部署在 Resin Web 应用程序服务器中。我一直在对应用程序的新部分进行一些 XML 解析,并意识到我们的应用程序正在使用 Resin 类 进行解析。由于多种原因,我想摆脱这种情况并使用更标准的东西,因此我在我的resin配置文件中设置了这些系统属性(并将xerces jar添加到我的类路径中):

<system-property javax.xml.parsers.DocumentBuilderFactory="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>

<system-property javax.xml.parsers.SAXParserFactory="org.apache.xerces.jaxp.SAXParserFactoryImpl"/>

而且,现在我遇到了JSP编译错误在几个页面上(我猜 Resin 的内置解析器更宽松)。该错误显示:

org.xml.sax.SAXParseException: The value of attribute "title" associated with an element type "display:column" must not contain the '<' character.

并且,某些页面上的“display:column”标记确实在“title”属性中包含标记。这是一个例子:

<display:column scope='col' class=" appealColorBG  selectAllWidth" 
    title="<span class='centerThis'><label for='selectAll'>Select All</label><br />
            <input type='checkbox' name='selectAll' 
            id='selectAll' 
            onClick='selectAllCheckboxes();'/></span> " >

我知道这是一些丑陋的 JSP 代码,但它也是已经投入生产的代码,所以我犹豫是否要更改它。

有谁知道我可以设置 xerces 以便它允许 JSP 按原样编译的方法吗?

All,
I'm working on a java webapp that we deploy in the Resin web app server. I have been doing some XML parsing for a new part of the application, and realized that our app was using Resin classes to do the parsing. I wanted to get away from that and use something more standard for a number of reasons, so I set these system properties in my resin config file (and added the xerces jar to my classpath):

<system-property javax.xml.parsers.DocumentBuilderFactory="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>

<system-property javax.xml.parsers.SAXParserFactory="org.apache.xerces.jaxp.SAXParserFactoryImpl"/>

And, now I'm getting JSP compilation errors on several pages (I guess Resin's built in parser was more lenient). The error reads:

org.xml.sax.SAXParseException: The value of attribute "title" associated with an element type "display:column" must not contain the '<' character.

And, the 'display:column' tag on some pages does indeed contain markup in the 'title' attribute. Here's an example:

<display:column scope='col' class=" appealColorBG  selectAllWidth" 
    title="<span class='centerThis'><label for='selectAll'>Select All</label><br />
            <input type='checkbox' name='selectAll' 
            id='selectAll' 
            onClick='selectAllCheckboxes();'/></span> " >

That's some ugly JSP code, I know, but it's also code that's already in production, so I'm hesitant to change it.

Does anyone know of a way that I can set xerces so that it will allow the JSP to compile as is?

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

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

发布评论

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

评论(1

爱的故事 2024-09-05 14:23:46

那肯定是丑陋的 JSP 代码。

如果您在其上使用 XML 解析器,就会遇到问题。有效 XML 中的属性值不能包含“<”性格,正如 Xerces 告诉你的那样。

您能否告诉 Xerces 接受这一点值得怀疑,但是修复 XML 比让 XML 解析器接受不正确的 XML 更好。

您可能希望重新使用 Resin 类,直到您可以向 Xerces 提供正确的 XML,或者将 Resin 配置为不使用 XML 解析器作为其 JSP 编译的一部分 - 请参阅注释。

That's certainly ugly JSP code.

If you're using an XML parser on it, you've got a problem. Attribute values in valid XML can not contain the '<' character, as Xerces is telling you.

It's doubtful you can tell Xerces to accept this, but fixing the XML would be a better idea than talking an XML parser into accepting incorrect XML anyway.

You probably want to drop back to using the Resin classes until you can feed Xerces proper XML, or configure Resin to not use an XML parser as part of its JSP compilation - see comments.

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