我尝试构建spring服务教程,这是我的代码:
web.xml
<servlet>
<servlet-name>accounts</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-config.xml
/WEB-INF/app-config.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>accounts</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>这是我的控制器:
@Controller
public class AccountController {
@RequestMapping(value = "/accounts", method = RequestMethod.GET, produces = {"application/json"})
@ResponseStatus(HttpStatus.OK)
public List<Account> accountSummary() {
return accountManager.getAllAccounts();
}
}当我用url:http://localhost:8080/rest-ws/app/accounts打开浏览器时,我得到了以下错误:
javax.servlet.ServletException: Circular view path [accounts]: would dispatch back to the current handler URL [/rest-ws/app/accounts] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)我错过了什么?
发布于 2015-09-15 12:01:56
试试这个:
@Controller
@RequestMapping(value = "/accounts")
public class AccountController {
@RequestMapping(value = "/list",
method = RequestMethod.GET, produces = {"application/json"})
@ResponseStatus(HttpStatus.OK)
public List<Account> accountSummary() {
return accountManager.getAllAccounts();
}
}打开:
http://localhost:8080/rest-ws/app/accounts/list啊,真灵?
https://stackoverflow.com/questions/32585472
复制相似问题