Springmvc.xml 添加
<mvc:default-servlet-handler />
<!--扫描包 -->
<context:component-scanbase-package="com.cn.controller"/>
<!--注解驱动 -->
<mvc:annotation-driven/>
<!--视图解析器 -->
<beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver">
<propertyname="prefix"value="/WEB-INF/html/"></property>
<propertyname="suffix"value=".html"></property>
</bean>
<!--配置静态资源处理器 -->
<mvc:resourceslocation="/js/"mapping="/js/**"/>
<mvc:resourceslocation="/css/"mapping="/css/**"/>
<mvc:resourceslocation="/imges/"mapping="/imges/**"/>
<!--处理静态资源被 '/'拦截 -->
<mvc:default-servlet-handler />
页面放到对应的路径下
PageShowController.java
@Controller
public classPageShowController {
@RequestMapping(value = "/about",produces = "text/html;charset=UTF-8")
public String about(){
return "about";
}
@RequestMapping(value ="/explain",produces = "text/html;charset=UTF-8")
public String explain(){
return"explain";
}
@RequestMapping(value ="/download",produces = "text/html;charset=UTF-8")
public String download(){
return"download";
}
}
来源:CSDN
作者:LLLiiv
链接:https://blog.csdn.net/llllvvv/article/details/75634248