Issue 1:
Przemek Ch opened SPR-8732 and commented

Method

protected String autogenerateId() throws JspException {
return StringUtils.deleteAny(getName(), "[]");
}

form AbstractDataBoundFormElementTag class doesn't work with freemarker.

Example

<@spring.formInput path="lead.additionalSalesList[1].saleResult.policyId" attributes='class="policyId_1"'/>

generates

<input id="additionalSalesList[1].saleResult.policyId" class="policyId_0" type="text" value="" name="additionalSalesList[1].saleResult.policyId">

According to https://jira.springsource.org/browse/SPR-2380 the code above should generate id="additionalSalesList1.saleResult.policyId"

[] in ID is not a valid HTML so libraries like jQuery cant handle such elements

Tricks like this $(":input[name='additionalSalesList[1]\\.saleResult\\.policyId']") are needed now to select such items using jQuery.

Affects: 3.0.6

Issue Links:

#12366 Using array syntax generates invalid id in freemarker ("duplicates")

#9845 Binding in Velocity templates using EL accessors ([, ]) for collections produces non xhtml strict compliant output

Referenced from: commits ba03d5b, e7e74c8, a9f4206

2 votes, 5 watchers

Issue 2:
Ken Egervari opened SPR-6163 and commented

Using ignore accept header and default content type causes problems. Here is my bean xml:

{code?xml}

<bean id="contentNegotiatingViewResolver"

class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">

<property name="order" value="1"/>

<property name="ignoreAcceptHeader" value="true" />

<property name="defaultContentType" value="text/html" />

<property name="mediaTypes">

<map>

<entry key="ftl" value="text/html"/>

<entry key="xml" value="application/xml"/>

<entry key="json" value="application/json"/>

<entry key="atom" value="application/atom+xml"/>

<entry key="rss" value="application/rss+xml"/>

</map>

</property>

<property name="defaultViews">

<list>

<bean class="org.springframework.web.servlet.view.xml.MarshallingView">

<property name="contentType" value="application/xml" />

<property name="marshaller">

<bean class="org.springframework.oxm.xstream.XStreamMarshaller">

<property name="autodetectAnnotations" value="true"/>

</bean>

</property>

</bean>

<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">

<property name="contentType" value="application/json" />

</bean>

</list>

</property>

<property name="viewResolvers">

<list>

<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">

<property name="contentType" value="text/html" />

<property name="order" value="2"/>

<property name="cache" value="false"/>

<property name="prefix" value=""/>

<property name="suffix" value=".ftl"/>

<property name="exposeSpringMacroHelpers" value="true"/>

</bean>

</list>

</property>

</bean>

Here is the exception that is generated:

SEVERE: Servlet.service() for servlet jawbs threw exception

java.lang.UnsupportedOperationException

at java.util.AbstractList.set(AbstractList.java:115)

at java.util.AbstractList$ListItr.set(AbstractList.java:412)

at java.util.Collections.sort(Collections.java:121)

at org.springframework.web.servlet.view.ContentNegotiatingViewResolver.resolveViewName(ContentNegotiatingViewResolver.java:344)

at org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1105)

at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1052)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:808)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:726)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:636)

at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:545)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

If there is a short-term fix, I'd love to hear it.

Basically what I want to do is have no extension (like /rest/hotels/list) go to text/html and still have the json, xml, etc. views work with the extensions on any/all browsers.

Thanks!

Affects: 3.0 RC1

Issue Links:

#10846 Using defaultContentType property in ContentNegotiatingViewResolver throws java.lang.UnsupportedOperationException ("is duplicated by")

Referenced from: commits 0c47a01