刚刚初学Spring MVC,却连一个简单的helloworld都搞的懵懵懂懂的,配置文件搞不清,各种文件之间的逻辑关系也不懂,连续看了好些日子的Spring MVC了,今天终于下定决心,每天记录一点,下面是web.xml中的配置文件。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5"> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/root-context.xml</param-value>
</context-param> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter> <filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- <filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter> <filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> --> <!-- HiddenHttpMethodFilter,因为html中的form表单只支持GET与POST请求,spring为了支持DELETE, PUT等操作,会在生成页面代码时,会把我们希望的操作添加到一个hidden的_method中,在外层通过post传过去,所以我们需要通过 HiddenHttpMethodFilter把真实的操作解析出来。 -->
<!-- <filter>
<filter-name>hiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hiddenHttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> --> <servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping> <welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list> <error-page>
<error-code>404</error-code>
<location>/404</location>
</error-page> <!-- <error-page>
<error-code>500</error-code>
<location>/500</location>
</error-page>
-->
</web-app>

在SpringMVC框架下建立Web项目时web.xml到底该写些什么呢?的更多相关文章

  1. 导入java web项目时 web.xml第一行报错

    报错信息: Referenced file contains errors (http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd). For more infor ...

  2. SpringMVC框架下Web项目的搭建与部署

    这篇文章已被废弃. 现在,Deolin使用Maven构建项目,而不是下载Jar文件,使用Jetty插件调试项目,而不是外部启动Tomcat. SpringMVC比起Servlet/JSP方便了太多 W ...

  3. 使用Eclipse创建Web项目时WEB-INF下找不到web.xml问题详解

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/yjrguxing/article/deta ...

  4. eclipse 使用tomcat7.0建立Dynamic Web Project 时 web.xml的问题

    最近使用Eclipse helios版本结合tomcat7.0建立动态的web项目时,发现在WEB-INF下的web.xml没有了. 解决方案: 建立web项目时,建到第三个下一步时,将 Genera ...

  5. 使用Javamelody验证struts-spring框架与springMVC框架下action的訪问效率

    在前文中我提到了关于为何要使用springMVC的问题,当中一点是使用springMVC比起原先的struts+spring框架在效率上是有优势的.为了验证这个问题,我做了两个Demo来验证究竟是不是 ...

  6. 做web项目时对代码改动后浏览器端不生效的应对方法(持续更新)

    做web项目时,常常会遇到改动了代码,但浏览器端没有生效,原因是多种多样的,我会依据我遇到的情况逐步更新解决的方法 1.执行的时候採用debug模式,普通情况下使用项目部署button右边那个butt ...

  7. 做web项目时对代码修改后浏览器端不生效的应对方法(持续更新)

    做web项目时,经常会遇到修改了代码,但浏览器端没有生效,原因是多种多样的,我会根据我遇到的情况逐步更新解决办法 1.运行的时候采用debug模式,一般情况下使用项目部署按钮右边那个按钮下的tomca ...

  8. (转)springMVC框架下JQuery传递并解析Json数据

    springMVC框架下JQuery传递并解析Json数据 json作为一种轻量级的数据交换格式,在前后台数据交换中占据着非常重要的地位.Json的语法非常简单,采用的是键值对表示形式.JSON 可以 ...

  9. Eclipse中发布Maven管理的Web项目时找不到类的问题根源和解决办法(转)

    转自:http://blog.csdn.net/lvguanming/article/details/37812579?locationNum=12 写在前面的话 现在是越来越太原讨厌Eclipse这 ...

随机推荐

  1. AOP举例子

    切面类TestAspect package com.spring.aop; /** * 切面 * */ public class TestAspect { public void doAfter(Jo ...

  2. MPI Maelstrom(Dijkstra)

    http://poj.org/problem?id=1502 刷一道模板题稳定一下心情... Dijkstra求单源最短路,就是输入的时候注意下,是按下三角输入的(无向图),输入字符x表示i与j不通. ...

  3. codeforce-191E-Thwarting Demonstrations(树状数组+二分+离散)

    题意: 求第K 大连续区间 分析: 二分答案,再n * log(n)判断有几个区间的区间和大于mid,然后调整上下界,使这个值不断的接近k. 判断符合条件的区间总数:线性扫描sum[n](前n项和) ...

  4. 【转】 为SeekBar滑块设置固定值以及自定义Seekbar,progressbar样式--不错

    原文网址:http://blog.csdn.net/jdsjlzx/article/details/7804080 最近在项目中使用到了seekbar和progressbar,且必须按照设计要求来进行 ...

  5. 数据结构(主席树):COGS 2213. K个串

    2213. K个串 ★★★★   输入文件:bzoj_4504.in   输出文件:bzoj_4504.out   简单对比时间限制:20 s   内存限制:512 MB [题目描述] 兔子们在玩k个 ...

  6. 网络流(最大流) CQOI 2015 BZOJ 3931 网络吞吐量

    3931: [CQOI2015]网络吞吐量 Description 路由是指通过计算机网络把信息从源地址传输到目的地址的活 动,也是计算机网络设计中的重点和难点.网络中实现路由转发的硬件设备称为路由器 ...

  7. 201512读书分享——读《做自己的No.1》“哪一天”是永远不会到来的

    在看这本书的同时,最近也看了一部电影叫做<令人怦然心动的人生整理魔法>,讲一个女孩子平常不善收理,然后房间和人生乱七八糟,她总想着“等哪一天有空了就收拾”.但是,最终一句话打醒了——“哪一 ...

  8. ubuntu 下修改host文件

    原文地址:http://www.cnblogs.com/kingcat/archive/2012/02/23/2364509.html 有些时候,我们需要让某些域名指向本地,来实现调试,下面介绍下ub ...

  9. legoblock秀上限

    很久没有做题了,前天做了一道题结果弱的一逼...搜了解题报告不说...还尼玛秀了上限 题意: 给出宽和高为n和m的一堵墙,手上有长为1,2,3,4高均为1的砖,问形成一个坚固的墙有多少种做法. 坚固的 ...

  10. poj 1269 水题

    题目链接:http://poj.org/problem?id=1269 #include<cstdio> #include<cstring> #include<cmath ...