Spring MVC3 Rest Call使用angular获取http406 [英] Spring MVC3 Rest Call Getting http406 using angular
问题描述
这是我的环境
- Spring 3.2.8.RELEASE
- 包含jackson-mapper -asl-1.7.9.jar,jackson-core-asl-1.7.9.jar
- Tomcat 6.x
- mvc:annotation-在Spring配置XML文件中驱动
- Spring 3.2.8.RELEASE
- included jackson-mapper-asl-1.7.9.jar, jackson-core-asl-1.7.9.jar
- Tomcat 6.x
- mvc:annotation-driven in Spring configuration XML file
推荐答案
尝试在方法的请求映射中更改映射扩展名。
Try changing the mapping extension in the requestmapping of the method.
从春季3.2.x开始,映射的扩展比 Accept
和<$ c $普遍存在c>解析预期内容类型时的Content-Type 标题。因此,由于您已将映射定义为 .htm
,因此内容协商解析器希望它返回 html
,而不是其他任何内容。更多信息此处
As of spring 3.2.x onwards the extension of the mapping has prevalence over the Accept
and Content-Type
headers at the time of resolving the expected content types. So, as you have defined the mapping as .htm
, content negotiation resolver expects it to return html
and nothing else. More info here
所以使用非扩展映射或泛型映射(我通常使用 .service
扩展名定义我的其余映射)。
So use a non extension mapping or a generic one (I usually define my rest mappings with .service
extension).
在web.xml配置类中注意或查看spring的调度程序servlet映射,因为您可能需要更改或添加其他映射以使新映射到达您的控制器。
Be aware or reviewing the spring's dispatcher servlet mapping in web.xml o configuration class, as you might need to change or add additional mappings in order to make new mapping reach your controller.
这篇关于Spring MVC3 Rest Call使用angular获取http406的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!