我正在尝试使用 spring 实现长轮询,这是示例代码
这是我的异步方法的代码:
@RequestMapping(value= "failed.html" ,method = RequestMethod.POST)
protected Callable<String> callable(@ModelAttribute("user") Message user1, BindingResult bindingResult){
return new Callable<String>() {
@Override
public String call() throws Exception {
System.out.println("call--------->");
Thread.sleep(2000);
return "success";
}
};
}
这是 callablecontroller-servlet.xml:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<bean id= "viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix"><value></value></property>
<property name="suffix" value=".jsp"></property>
</bean>
<bean id="callable" class="spring.controller.CallableController">
</bean>
然而,“call------------”永远不会在控制台中打印出来,它会显示 failed.jsp 而不是 success.jsp。任何帮助,将不胜感激。