springMVC项目配置文件
一、springMVC项目配置文件
1、web.xml文件全局配置
<servlet>
<servlet-name> dispatcher </servlet-name>
<servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> dispatcher </servlet-name>
<url-pattern> / </url-pattern> //表示拦截所有请求,交由springMVC后台控制器来处理
</servlet-mapping>
//<servlet>、<servlet-mapping>这两个标签都是成对配置
2、dispatcher-servlet.xml //此处文件名xxx-servlet.xml中的xxx对应的是1中设置的Servlet-name
<beans>
<bean id = "SimpleUrlHandlerMapping" class = "org.springframework.web.servlet.Handler.SimpleUrlHandlerMapping">
<property name = "mapping">
<props>
<prop key = "/hello"> HelloController </prop> // /hello路径的请求交给id为HelloController的控制器处理,此处prop的值是下一个bean的id
</props>
</property>
</bean>
<bean id = "HelloController" class ="controller.HelloController"></bean>
</beans>
3、创建实现org.springframework.web.servlet.mvc.Controller接口的类HelloController
重写方法public ModelAndView handleRequest( HttpServletRequest p1, HttpServletResponse p2 ){
ModelAndView model = new ModelAndView("insex.jsp"); //视图
model.addObject( "message", "hello world!"); //模型数据是message,内容是hello world!
return model;
}
4、index.jsp中使用el表达式显示message的内容: <h1> ${ message } </h1>
springMVC项目配置文件的更多相关文章
- springmvc 项目完整示例02 项目创建-eclipse创建动态web项目 配置文件 junit单元测试
包结构 所需要的jar包直接拷贝到lib目录下 然后选定 build path 之后开始写项目代码 配置文件 ApplicationContext.xml <?xml version=" ...
- springmvc 项目完整示例04 整合mybatis mybatis所需要的jar包 mybatis配置文件 sql语句 mybatis应用
百度百科: MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBat ...
- springmvc 项目完整示例05 日志 --log4j整合 配置 log4j属性设置 log4j 配置文件 log4j应用
log4j 就是log for java嘛,老外都喜欢这样子,比如那个I18n ---internationalization 不就是i和n之间有18个字母... http://logging.a ...
- maven -- 学习笔记(四)实现在Eclipse用maven搭建springmvc项目(附构建步骤和详细实现代码)
Learn from:http://www.cnblogs.com/fangjins/archive/2012/05/06/2485459.html,感谢楼主的分享,才有下面的这篇学习小结 一.环境准 ...
- 项目搭建系列之一:使用Maven搭建SpringMVC项目
约定电脑都安装了eclipse,且已配置好Maven以及eclipse插件. 1.Eclipse 2.maven 3.Eclipse 需要安装maven插件.url:maven - http://do ...
- 3.SpringMVC修改配置文件路径和给界面传递数据
1.修改配置文件路径 达到 配置多文件的目的 web.xml文件中基础配置有springMVC配置的servlet路径 <servlet-name>SpringMVC</serv ...
- springmvc 项目完整示例06 日志–log4j 参数详细解析 log4j如何配置
Log4j由三个重要的组件构成: 日志信息的优先级 日志信息的输出目的地 日志信息的输出格式 日志信息的优先级从高到低有ERROR.WARN. INFO.DEBUG,分别用来指定这条日志信息的重要程度 ...
- springmvc学习笔记---idea创建springmvc项目
前言: 真的是很久没搞java的web服务开发了, 最近一次搞还是读研的时候, 想来感慨万千. 英雄没落, Eclipse的盟主地位隐隐然有被IntelliJ IDEA超越的趋势. Spring从2. ...
- springMVC项目国际化(i18n)实现方法
SpringMVC项目国际化(i18n)实现方法 按照作息规律,每周五晚必须是分享知识的时间\(^o^)/~,这周讲点儿啥呢,项目需要逼格,咱们国际化吧(* ̄rǒ ̄)~,项目中碰到这类需求的童鞋可能并 ...
随机推荐
- light oj 1214 - Large Division 大数除法
1214 - Large Division Given two integers, a and b, you should check whether a is divisible by b or n ...
- 4.【Spring Cloud Alibaba】服务容错-sentinel
雪崩效应 常见容错方案 超时 限流 仓壁模式 断路器模式 断路器三态转换 使用Sentinel实现容错 什么是Sentinel https://github.com/alibaba/Sentinel ...
- To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
mongoose报错:DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and wil ...
- OpenLayers 6 学习笔记
这个是真的学习笔记!不是教程 转载请声明:https://www.cnblogs.com/onsummer/p/12159366.html 基于openlayers 6.x api不太好查,就基于腾讯 ...
- win10安装两个不同版本的mysql(mysql5.7和mysql-8.0.19)
win10中安装mysql5.7后,安装mysql-8.0.19 在D:\mysql-8.0.19-winx64目录下创建一个my.ini文件 [mysqld] # 设置3307端口 port # 设 ...
- Linux分区工具-parted
parted用于操纵磁盘分区的程序,通常用于规则大小超过2T的分区,也可用于小分区的规划:它支持多种分区表格式,包括MS-DOS(MBR)和GPT:这对于为新操作系统创建空间,重新组织磁盘使用以及将数 ...
- [Python之路] bisect模块
bisect模块 bisect是Python提供的二分查找模块 源码如下: """Bisection algorithms.""" def ...
- 微软帮助类SqlHelper
using System; using System.Data; using System.Xml; using System.Data.SqlClient; using System.Collect ...
- java.math包下计算浮点数和整数的类
(1)BigIntege:实现任意精度的整数运算.(2)BigDecimal:实现任意精度的浮点运算. 例如: 使用BigDecimal进行浮点数比较 import java.math.BigDeci ...
- Java面向对象入门(2)-访问修饰符
Java访问修饰符–public, protected, private and default Java提供了四个访问修饰符来设置类,变量,方法和构造函数的访问级别,即public,private, ...