406(不可接受),从控制器获得响应但角度无法捕获它

时间:2017-10-20 13:19:39

标签: angularjs spring-mvc jackson

我正在尝试在表格中显示数据,我在控制器中获取列表但是angularjs不接受来自控制器的响应。我使用的是spring 4.3.10版本,hibernate 5.2.2 final和angularjs / 1.6.4 / angular.min.js。我没有得到如何解决这个问题。

  

LIB:

multiset
  

分配器一小服务程序:

jackson-annotations-2.6.5.jar  
jackson-core-2.6.5.jar  
jackson-databind-2.6.5.jar  
Spring 4.3.10  
hibernate 5.2.2 final
  

控制器:

<mvc:annotation-driven /> 
<context:component-scan base-package="com.scm" />
 <context:annotation-config />

 <tx:annotation-driven transaction-manager="hibernateTransactionManager" /> 

<bean   
class="org.springframework.web.servlet.mvc.method.
annotation.RequestMappingHandlerAdapter">
    <property name="messageConverters">
        <list>
            <ref bean="jsonMessageConverter"/>
        </list>
    </property>
</bean>

<bean id="jsonMessageConverter" 

class="org.springframework.http.converter.json.
MappingJackson2HttpMessageConverter">
</bean>  
  

获取方法:

@SuppressWarnings({ "unchecked", "unused", "rawtypes" })
@RequestMapping(value="/DMRequestToVCMD1",method=RequestMethod.GET, 
headers="Accept=application/json")
public @ResponseBody Map getCommodityCodes(Model model,HttpServletRequest 
request,HttpServletResponse response) {
    Map m = new HashMap();
    String uname = (String) session.getAttribute("user_name");
    String district_code = (String) session.getAttribute("district_code");
    List<AllotmentBean> list = null;
    String exception = null;
    try
    {
        list = scm_service.getAllotmentCommodities(uname);
        System.out.println("list=============="+list.size());
    }catch(Exception ex)
    {
        ex.printStackTrace();
        exception = ex.getMessage();
    }

    m.put("list", list);
    m.put("exception", exception);
    return m;   
 }

0 个答案:

没有答案