简体   繁体   English

更新到Java 7时Spring无效的动态属性

[英]Spring invalid dynamic attributes when updating to Java 7

I am in charge of a quite old website who was at first compiling with Java 5 and now Java 6. I'm using Spring 3.1. 我负责一个相当老的网站,该网站最初使用Java 5和Java 6进行编译。我使用的是Spring 3.1。

I'm trying to update from Java 6/ Tomcat 6 to Java 7 / Tomcat 7 and I have a lot of problems regarding the form tags. 我正在尝试从Java 6 / Tomcat 6更新到Java 7 / Tomcat 7,并且我在表单标签方面存在很多问题。

For this code: 对于此代码:

<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>    
...
<form:textarea path="myPath" placeholder="hello world" id="myId" rows="1" />

I get that error: 我得到那个错误:

Attribute placeholder invalid for tag textarea according to TLD

It seems that a lot of the attributes I was using before updating Java don't work anymore. 似乎我在更新Java之前使用的许多属性不再起作用。 Do you have any idea why? 你知道为什么吗? Thanks! 谢谢!

It looks like the WAR contains accidentally several versions of the TLD, and in Tomcat 6 the correct version is found, but on Tomcat 7 the wrong version is loaded instead. 看起来WAR意外包含了TLD的多个版本,并且在Tomcat 6中找到了正确的版本,但是在Tomcat 7上却加载了错误的版本。

If two different versions of the same jar are present in WEB-INF/lib, there is no way to predict which one will be chosen, the results are dependent on the classloader implementation details, and so different Tomcat versions might yield different results. 如果WEB-INF / lib中存在同一jar的两个不同版本,则无法预测将选择哪个版本,结果取决于类加载器的实现细节,因此不同的Tomcat版本可能会产生不同的结果。

To verify this, try looking in your IDE by the multiple versions of file spring.schemas . 要验证这一点,请尝试在IDE中查看spring.schemas文件的多个版本。 These files contain the mapping between url's such as http://www.springframework.org/tags/form and the XSDs /TLDs shipped inside the same jar. 这些文件包含URL(例如http://www.springframework.org/tags/form与同一罐子中随附的XSD / TLD之间的映射。

This mechanism exists for XSDs/TLDs that are not published online such as the url of this case, if you paste the url to a browser the file does not exist. 对于未在线发布的XSD / TLD(例如本例的url),存在此机制,如果将url粘贴到浏览器中,则该文件不存在。

In this case there should be two spring.schemas both with mention to url http://www.springframework.org/tags/form . 在这种情况下,应该有两个spring.schemas都提到了URL http://www.springframework.org/tags/form Remove the one with the wrong version of the XSD/TLD and it should work correctly in both Tomcat versions. 删除XSD / TLD版本错误的版本,它在两个Tomcat版本中均应正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM