一般maven(war)工程的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"
    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">
    <!-- <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern>
        </filter-mapping> -->

    <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>
    </filter>
    <filter-mapping>
        <filter-name>CharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- 过滤器。把post请求转化成put和delete,根据method -->

    <filter>
        <filter-name>hiddenFilter</filter-name>
        <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>hiddenFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>springDispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Map all requests to the DispatcherServlet for handling -->
    <servlet-mapping>
        <servlet-name>springDispatcherServlet</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>
        <servlet-mapping>
        <servlet-name>springDispatcherServlet</servlet-name>
        <url-pattern>/service/*</url-pattern>
    </servlet-mapping>
    <!-- needed for ContextLoaderListener -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:application*.xml</param-value>
    </context-param>

    <!-- Bootstraps the root web application context before servlet initialization -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

</web-app>

原文地址:https://www.cnblogs.com/sh-0131/p/11743064.html

时间: 2024-08-12 11:32:16

一般maven(war)工程的web.xml文件的相关文章

关于Java Web工程中web.xml文件

提及Java Web工程中web.xml文件无人不知,无人不识,呵呵呵:系统首页.servlet.filter.listener和设置session过期时限,张口就来,可是你见过该文件中的error-page标签吗?下面直接以例子的形式说明error-page标签的使用: 一个servlet文件: package com.ghj.packageofservlet; import java.io.IOException; import javax.servlet.ServletException;

Eclipse 创建web工程后没有web.xml文件

问题: 今天换了台机器,重新安装了JDK, Eclipse. 创建了一个web工程,奇怪的发现创建好的工程没有web.xml文件,再试了几次依然是同样的结果,奇怪,web.xml文件哪里去了,怎么破? 解决方法: 不是大问题,没有web.xml 是因为在创建工程的时候没有选择web.xml所致,在创建工程时不要选择finish直接完成,建议选择next,在第三步勾选Generate web.xml development descriptor.

IDEA导入maven工程以及web.xml中spring配置文件文件加载不到的问题

使用idea导入maven工程,工程只留了src和pom.xml文件 1.从打开idea中导入:File ----> New -----> Project from Existing Sources.如下图: 2.选择你所要导入的项目.点击ok 3.一定要选择; 第二个  :Import project from external model    从外部模型导入项目,然后点击Next 4.下一步......选择你需要的jdk.然后:项目名称一定和文件名称一致,然后点击Filish就OK了 首

解决新建maven工程没有web.xml的问题

首先确定创建maven工程时选择的打包方式为 war 创建后如图所示没有web.xml文件以及相关文件夹,错误信息:缺少web.xml文件 解决方法: 右击maven项目,找到ProjectFacets 取消选中 Dynamic Web Module选项,点击应用,再选中Dyanmic Web Module会出现一个选项卡 点击弹出的选项卡后 输入src/main/webapp点击OK web.xml已经出现,错误信息也消除了. 原文地址:https://www.cnblogs.com/chen

tomcat下web.xml文件修改后工程重启的原因

$tomcat/conf/context.xml文件中的配置,监听了WEB-INF/web.xml文件 <?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for

web.xml文件的作用

每个javaEE工程中都有web.xml文件,那么它的作用是什么呢?它是每个web.xml工程都必须的吗? 一个web中可以没有web.xml文件,也就是说,web.xml文件并不是web工程必须的. web.xml文件是用来初始化配置信息:比如Welcome页面.servlet.servlet-mapping.filter.listener.启动加载级别等. 当你的web工程没用到这些时,你可以不用web.xml文件来配置你的Application. 每个xml文件都有定义它书写规则的Sche

web.xml 文件配置01

web.xml 文件配置01 前言:一般的web工程中都会用到web.xml,方便开发web工程.web.xml主要用来配置Filter.Listener.Servlet等.但是要说明的是web.xml并不是必须的,一个web工程可以没有web.xml文件. 1.定义头和根元素 部署描述符文件就像所有XML文件一样,必须以一个XML头开始.这个头声明可以使用的XML版本并给出文 件的字符编码.web.xml的模式文件是由Sun公司定义的,每个web.xml文件的根元素<web-app>中,都必

web.xml文件详解

web.xml文件详解 前言:一般的web工程中都会用到web.xml,web.xml主要用来配置,可以方便的开发web工程.web.xml主要用来配置Filter.Listener.Servlet等.但是要说明的是web.xml并不是必须的,一个web工程可以没有web.xml文件. 1.WEB工程加载web.xml过程 经过个人测试,WEB工程加载顺序与元素节点在文件中的配置顺序无关.即不会因为 filter 写在 listener 的前面而会先加载 filter.WEB容器的加载顺序是:S

web.xml文件的作用及基本配置

Java的web工程中的web.xml文件有什么作用呢?它是每个web工程都必须的吗? 一个web中完全可以没有web.xml文件,也就是说,web.xml文件并不是web工程必须的. 那什么时候需要,什么时候可以不需要呢? 要想回答上面的问题,得先了解web.xml文件是用来干什么的.web.xml文件是用来配置:欢迎页.servlet.filter等的.当你的web工程没用到这些时,你可以不用web.xml文件来配置你的web工程. 那么web.xml能做的所有事情都有那些? 其实,web.