我在Controller作如下映射时,无法解析出jsp视图(不可访问localhost:8080/MyProject/myJsp.jsp,报404)
@Controller public class PageController { @RequestMapping("/{url}.jsp") public String jspPage(@PathVariable String url) { System.out.println("aaaaa"); return "jsp/" + url + ".jsp"; } }
但是改成这样却可以:(可访问localhost:8080/MyProject/myJsp.jspp)
@Controller public class PageController { @RequestMapping("/{url}.jspp") public String jspPage(@PathVariable String url) { System.out.println("aaaaa"); return "jsp/" + url + ".jsp"; } }
视图解析器配置如下:
//...
//前面还有一个Velocity视图解析器
//
//
<!-- JSP视图解析器 --> <bean id="viewResolverJsp" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/page/"/> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="viewNames" value="*.jsp" /> <property name="suffix" value=""/> <property name="order" value="1"/> </bean>
工程目录结构:
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
不建议配置*.jsp , 这个应该是被过滤掉了,不知道是不是关键字,还没时间看源码,
如果想直接访问WEB-INF下的页面,可以 配置,
可以参考:教你一步步搭建ssm框架,第一步实现springmvc下的页面跳转 - 2018