在我的应用程序的webapp文件夹下,我有一个名为会议室的文件夹 在该文件夹中,我有一个名为 viewrooms.jsp
的jsp页面- DispatcherServlet 配置如下:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring/config/applicationContext.xml
</param-value>
</context-param>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/config/applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/meetingroom/*</url-pattern>
</servlet-mapping>
- InternalResourceViewResolver bean:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
- 控制器:
@Controller
@RequestMapping("/viewrooms.jsp")
public class ViewRooms {
@RequestMapping(method = RequestMethod.GET)
public String get() {
log.debug("######## GET METHOD FOR VIEW ROOMS ########");
return "meetingroom/viewrooms";
}
}
http://localhost:8081/MyAPP/meetingroom/viewrooms.jsp
ISSUE:控制器get方法在无限循环中被调用,页面不会被渲染。
请告知为什么它不起作用,谢谢。
答案 0 :(得分:1)
IMHO @RequestMapping(“/ viewrooms.jsp”)指向/MyAPP/viewrooms.jsp 将@RequestMapping更改为“/meetingroom/viewrooms.jsp”将是我对您的问题的修复的下一个猜测
答案 1 :(得分:0)
问题,可能是与servlet url映射冲突。