1. Redirection
<mvc:view-controller path="/" view-name="redirect:/admin/index"/>
That is, if the current path is /, redirect to /admin/index
2, view name
<mvc:view-controller path="/" view-name="admin/index"/>
If the current path is /, it is handed over to the corresponding view resolver to resolve directly to the view,
such as
<bean id="defaultViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:order="2"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="contentType" value="text/html"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean>
When you get the view /WEB-INF/jsp/admin/index.jsp
does not want to enter the controller, you can configure the static access path in spring-mvc.xml
<!-- Access static resource files--> <mvc:resources mapping="/images/**" location="/images/" cache-period="31556926"/>
Like this, if the jsp file is placed under the static path /images, it can be accessed directly without going through the controller.