SpringMVC默认首页设置
来源:互联网 发布:百度蜘蛛软件 编辑:程序博客网 时间:2024/05/07 14:04
使用SpringMVC框架搭建Web,在web.xml中添加
<welcome-file-list> <welcome-file>index.htm</welcome-file></welcome-file-list>
发现不能识别首页,看来不是像Web工程一样进行简单的设置。
SpringMVC使用拦截机制,需要进行Servlet映射,添加一个新的扩展名,总而言之,需要在web.xml中加入以下设置:
<servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/index</url-pattern></servlet-mapping>
和
<welcome-file-list> <welcome-file>index</welcome-file> </welcome-file-list>
根据SpringMVC机制,数据被封装成请求后会去寻找相应的控制器(controller),根据你在applicationContext.xml中的设置,寻找控制器的地址,比如:
<context:component-scan base-package="com.wisu.xitiancheng"> <context:exclude-filter type="regex" expression="com.wisu.xitiancheng.control.*"/></context:component-scan>
在控制器中添加默认首页控制器,比如:
/*** 默认首页控制器*/@RequestMapping("/index")public String login(HttpServletRequest request, HttpServletResponse response){ return "index";}
//根据返回的值通过视图解析器查找相应的页面返回给用户
0 0
- SpringMVC默认首页设置
- springmvc 设置默认首页
- SpringMVC设置默认请求首页
- springMVC 配置默认首页
- springmvc默认首页问题
- Apache设置默认首页
- struts2设置默认首页
- apache设置默认首页
- Springmvc 默认首页的问题
- web项目设置默认首页
- IIS7 如何设置默认首页
- spring mvc 设置默认首页
- Apache中设置默认首页
- Spring MVC默认首页设置
- Apache中设置默认首页
- JAVA web设置默认首页
- springMVC中设置首页问题
- Js:添加收藏/设置默认首页
- Ubuntu 基础
- backlight子系统一
- java反射获取对象的属性及属性值
- Spring Security 学习之X.509认证
- Merge Sorted Array
- SpringMVC默认首页设置
- C语言运算符优先级和口诀
- sqli注入的方法以及可能导致sql注入的地方
- open url
- vim的基本够用操作
- NYOJ 206 矩形的个数
- 相于Repeater中使用绑定下拉列表一事 .
- 记录一列数据的顺序的思路
- 华为面试题(8分钟写出代码)