开发者

ResponseBody cannot be resolved to a type

I'm trying to write this method in my controller:

    @ResponseBody
@RequestMapping(value = {"/getTeams"}, method = RequestMethod.GET)
public void getMaxRequestSize(HttpServletResponse response) {
    String autoCompleteList = null;
    List<Team> teams = atService.getAllTeams();
    Iterator itr = teams.iterator();开发者_运维技巧
    while (itr.hasNext()) {
        autoCompleteList += itr.next().toString() + "\n";
    }
    response.setContentType("text/html");
    PrintWriter writer;
    try {
        writer = response.getWriter();
        writer.write(autoCompleteList);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

For some reason I always get an error on the ResponseBody annotation (= cannot be resolved to a type). I googled for quite a while and didn't find a solution. I'm sure it's something silly. I can use all the other annotations without any problems...


Is this a Maven project? You might be ending up with the old Spring 2.5.6 jars in your war file instead of Spring 3. Eclipse's POM editor's Dependency Hierarchy tab can help you figure out if that's the case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜