У кого-нибудь есть пример использования Spring RssChannelHttpMessageConverter для генерации подкаста rss?
Это то, что у меня есть.
@Controller
public class FeedController {
private Jaxb2Marshaller jaxb2Mashaller;
@Autowired
public void setJaxb2Mashaller(Jaxb2Marshaller jaxb2Mashaller) {
this.jaxb2Mashaller = jaxb2Mashaller;
}
@RequestMapping(method= RequestMethod.GET, value="/emps",
headers="Accept=application/rss+xml")
public @ResponseBody SyndFeed getFeed(){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Query query = session.createQuery("from Show");
List<Show> l = query.list();
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("rss2.0");
feed.setTitle("some podcast");
feed.setLink("you");
feed.setDescription("description");
feed.setCopyright("c_me");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
for(Show e : l) {
SyndEntry entry = new SyndEntryImpl();
entry.setTitle(e.getTitle());
entries.add(entry);
}
feed.setEntries(entries);
System.out.println(feed);
return feed;
}
}
При вызове контроллера я получаю 406Неприемлемо
Вот некоторые фрагменты моего весеннего конфига
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="marshallingConverter" />
<ref bean="atomConverter" />
<ref bean="jsonConverter" />
</list>
</property>
</bean>
<bean id="marshallingConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<constructor-arg ref="jaxbMarshaller" />
<property name="supportedMediaTypes" value="application/xml"/>
</bean>
<bean id="atomConverter" class="org.springframework.http.converter.feed.RssChannelHttpMessageConverter">
<property name="supportedMediaTypes" value="application/rss+xml" />
</bean>
<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json" />
</bean>
<!-- Client -->
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<ref bean="marshallingConverter" />
<ref bean="atomConverter" />
<ref bean="jsonConverter" />
</list>
</property>
</bean>
<bean id="jaxbMarshaller"
class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.Show</value>
</list>
</property>
</bean>