java ee

来源:互联网 发布:松下plc编程软件序列号 编辑:程序博客网 时间:2024/04/28 13:02
web.xml配置详解

    http://blog.sina.com.cn/s/blog_5a08b1780100bjdi.html

U​R​L​R​e​w​r​i​t​e​配置
    官方站点http://tuckey.org/urlrewrite/

log4j配置
    http://www.360doc.com/content/12/0717/17/7656232_224765999.shtml
    http://outofmemory.cn/code-snippet/4372/log4j-config-java-logging

HTTP状态码详解

    http://tool.oschina.net/commons?type=5


====================================================================================

====================================================================================

    1、pom.xml
==================================
<!-- url rewrite -->
<dependency>
    <groupId>org.tuckey</groupId>
    <artifactId>urlrewritefilter</artifactId>
    <version>3.1.0</version>
</dependency>
==================================
    2、web.xml
==================================
    <!-- UrlRewrite filter -->
    <filter>
        <filter-name>urlRewriteFilter</filter-name>
        <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>urlRewriteFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
==================================
    3、web-inf中要编写urlrewrite.xml
==================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE urlrewrite
        PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
        "http://tuckey.org/res/dtds/urlrewrite3.0.dtd">
<urlrewrite>
    <rule>
        <from>^/uploadImage/([0-9]+)-([1,2])\.upload$</from>
        <to type="forward">/upload.action?id=$1&amp;ioTag=$2</to>
    </rule>
</urlrewrite>
*******************************************
rule是url重写规则,from是显示出来的地址,to是映射的实际地址,$1是重写参数,可以为多个,()里是匹配的正则表达式.
注意:此配置?要换成/?  &要换成&amp;
==================================

Struts2配置
    1、导入jar包
    2、web.xml
==================================
    <!-- Struts2 filter -->
    <filter>
        <filter-name>struts2Filter</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter>
        <filter-name>struts2CleanupFilter</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
    </filter>

        <filter-mapping>
        <filter-name>struts2CleanupFilter</filter-name>
        <url-pattern>*.action</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>struts2Filter</filter-name>
        <url-pattern>*.action</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
==================================
    3、struts.xml(src/main/resources)
==================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
        "http://struts.apache.org/dtds/struts-2.1.dtd">

<struts>
    <constant name="struts.convention.package.locators" value="web,action" />
    <constant name="struts.convention.package.locators.basePackage" value="com.tianxun.esb" />    
</struts>
*******************************************
struts.convention.package.locators 确定搜索包的路径。只要是结尾为action的包都要搜索。
struts.convention.package.locators.basePackage 这个属性用于约定Action 类的根包(这个包是Java 类的包,而不是Struts.xml中配置的<package>节点)
==================================



Spring配置
    1、web.xml
==================================
    <!-- Spring ApplicationContext配置文件的路径,可使用通配符,多个路径用,号分隔
          此参数用于后面的Spring Context Loader -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath*:/applicationContext-web.xml
        </param-value>
    </context-param>

    <!-- Character Encoding filter -->
    <filter>
        <filter-name>encodingFilter</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>

    <!--Spring的ApplicationContext 载入 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- Spring 刷新Introspector防止内存泄露 -->
    <listener>
        <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
    </listener>
==================================
    applicationContext-web.xml

==================================
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
        <property name="ignoreResourceNotFound" value="true" />
        <property name="locations">
            <list>
                <value>classpath*:/application.properties</value>
                <value>classpath:/application.properties</value>
            </list>
        </property>
    </bean>

    <import resource="applicationContext.xml" />
</beans>
==================================
    applicationContext.xml
==================================
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
    default-lazy-init="true">

    <description>Spring公共配置</description>
    <!-- 使用annotation 自动注册bean,并检查@Required,@Autowired的属性已被注入 -->
    <context:component-scan base-package="com.tianxun" />
    <!-- 以静态变量保存ApplicationContext -->
    <bean class="com.tianxun.esb.utils.spring.SpringContextHolder" lazy-init="false" />
</beans>
==================================

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 红烧肉做的太甜怎么办 红烧排骨太甜了怎么办 唱歌时嗓子有痰怎么办 一唱歌喉咙有痰怎么办 鼻子老是打喷嚏还流鼻涕怎么办 鼻涕流到喉咙里怎么办 鼻塞怎么办怎样让鼻通气 流清鼻涕嗓子疼怎么办 喉咙疼咳嗽有痰怎么办 扁桃体发炎痛得厉害怎么办 腭垂掉下来了怎么办 喉咙干有异物感怎么办 嗓子干有异物感怎么办 输液的时候手疼怎么办 一感冒就嗓子哑怎么办 4岁儿童喉咙沙哑怎么办 嗓子老有异物感怎么办 喉咙咽口水都疼怎么办? 舌头上长了溃疡怎么办 包包的拉链坏了怎么办 做试管取精困难怎么办 sw过膝靴往下掉怎么办 如果被绑架了该怎么办 怀孕了%2c怎么办%3f 狗狗拉肚子怎么办带血 同学们不和我玩怎么办 懒癌和拖延症怎么办 有严重的拖延症怎么办 有拖延症的人怎么办 10多天月经不停怎么办 20多天月经不停怎么办 月经来了十几天不停怎么办 例假20多天不停怎么办 苹果6dns被劫持怎么办 工地欠工资不给怎么办 买的狗得病了怎么办 剖腹产9天刀口痒怎么办 剖腹产6天刀口痒怎么办 剖腹产2年刀口痒怎么办 破腹产9天刀口痒怎么办 破腹产7天刀口痒怎么办