第一种:
通过jsp跳转到spring mvc 配置好的controller
web.xml文件
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
index.jsp
<%@ page contentType="text/html;charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!-- 利用index.jsp调转过去 -->
<c:redirect url="/user/toUser">
</c:redirect>
spingmvc 类的控制方法映射@RequestMapping(value="/user/toUser")
第二种:
直接在springmvc 配置
@RequestMapping(value = "/")
public String index() {
return "jquery";
}
第三种:
在spring-servlet.xml文件配置指定
<mvc:view-controller path="/" view-name="jquery"/>
也可以用注解
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("home");
}
}
spring mvc欢迎页面跳转的方法
猜你喜欢
转载自xuxiaohongok.iteye.com/blog/2054274
今日推荐
周排行