@Controller
@RequestMapping(value="admin/*", method=RequestMethod.GET)
public class AdminController {
@Autowired
private HttpServletRequest request;
@Autowired
private HttpServletResponse response;
@RequestMapping
public ResponseEntity<String> test0() {
System.out.println("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ");
return null;
}
}
和标签:
在我的config.xml<mvc:annotation-driven />
这应该是足够我的感觉,但有@Autowired的问题:
没有匹配的类型为[javax.servlet.http.HttpServlet回复]发现依赖:预计至少有1豆有资格...
我见过一些解决方案提到设置豆等,但我相信必须有一些更好的方法。注释扫描应该考虑到这一点。如果我必须在不同的时间在xml中为几个不同的注释设置bean,那就太糟糕了。我只是想让注释在我使用它们的时候起作用!
谢谢!
可能的重复:http://stackoverflow.com/questions/6984054/autowired-httpservletresponse – Kevin 2012-03-15 14:41:26