【发布时间】:2011-12-06 11:58:44
【问题描述】:
我正在使用 Spring MVC 3 构建一个带有 RESTful Web 服务的 Web 应用程序。Web 服务将被应用程序使用,因此永远不应该真正解决对视图的任何请求。有没有办法在 servlet 上下文中指定任何请求都不应解析为任何视图?
目前,我有:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
我知道它会尝试将任何请求解析为jsp 文件夹中相应命名的视图。但是,如果我删除它,应用程序只会尝试使用默认视图解析器。
我担心这一点的原因是我的应用程序日志将充满以下消息(即使它工作正常):
SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [/vouchd] threw exception [Circular view path [signup]: would dispatch back to the current handler URL [/vouchd/signup] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)] with root cause
javax.servlet.ServletException: Circular view path [signup]: would dispatch back to the current handler URL [/vouchd/signup] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
或使用InternalViewResolver:
WARN [http-bio-8080-exec-4] (DispatcherServlet.java:1057) - No mapping found for HTTP request with URI [/app/WEB-INF/jsp/call.jsp] in DispatcherServlet with name 'DispatcherServlet'
我猜这是两个弊端中更好的一个。我不想关闭日志记录 WARN 级别。
【问题讨论】:
标签: rest spring-mvc