參考代码例如以下:

com.atguigu.struts2.app.converters.DateConverter.java

public DateFormat getDateFormat(){

if(dateFormat ==
null){

//获取当前 WEB
应用的初始化參数 pattern(该參数在WEB-INF下的web.xml文件里)

//第一次用的时候获取,并载入相关的信息

//这样的方法是使用/struts2-6/src/xwork-conversion.properties配置文件

//xwork-conversion.properties配置文件的内容:

//java.util.Date=com.atguigu.struts2.app.converters.DateConverter

ServletContext servletContext = ServletActionContext.getServletContext();

System.out.println(servletContext);

String pattern = servletContext.getInitParameter("pattern");

dateFormat =
new
SimpleDateFormat(pattern);

}

return
dateFormat;

}

如何获得(读取)web.xml配置文件的參数的更多相关文章

  1. web.xml配置文件的简单说明

    简单说一下,web.xml的加载过程.当我们启动一个WEB项目容器时,容器包括(JBoss,Tomcat等).首先会去读取web.xml配置文件里的配置,当这一步骤没有出错并且完成之后,项目才能正常的 ...

  2. web.xml 配置文件 超详细说明!!!

    一.web.xml是什么? 首先 web.xml 是java web 项目的一个重要的配置文件,但是web.xml文件并不是Java web工程必须的. web.xml文件是用来配置:欢迎页.serv ...

  3. 史上最全web.xml配置文件元素详解

    一.web.xml配置文件常用元素及其意义预览 <web-app> <!--定义了WEB应用的名字--> <display-name></display-na ...

  4. web.xml配置文件

    一.web.xml里面的标签 <display-name> <context-param> <listener> <filter> 和 <filt ...

  5. eclipse创建web项目web.xml配置文件笔记

    1.使用eclipse创建web项目时,如果直接finish的话就没有默认生成web.xml配置文件,此时在你的项目下是看不到web.xml配置文件的,如果要查看的话可以如下操作: 右键你的项目,然后 ...

  6. web.xml配置文件中<async-supported>true</async-supported>报错

    web.xml配置文件中<async-supported>true</async-supported>报错 http://blog.csdn.net/dream_ll/arti ...

  7. web.xml配置文件元素详解

    一.web.xml配置文件常用元素及其意义 1 <web-app> 2 3 <!--定义了WEB应用的名字--> 4 <display-name></disp ...

  8. ssm框架 spring的主配置文件 spring-mvc主配置文件 web.xml配置文件(基础的配置文件)

    1.spring主配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=" ...

  9. Java web 项目 web.xml 配置文件加载过程

    转载自:http://blog.csdn.net/luoliehe/article/details/46884757#comments WEB加载web.xml初始化过程: 在启动Web项目时,容器( ...

随机推荐

  1. TOJ1196: RSA Signing

    题不在多,大概是多了也可能就是菜逼 1196: RSA Signing Time Limit(Common/Java):3000MS/30000MS     Memory Limit:65536KBy ...

  2. 二进制<3>

    Matrix67:位运算简介及实用技巧(三) 进阶篇(2) (2010-07-27 11:10:44) 转载▼ 标签: it 分类: 老贾·OI相关 n皇后问题位运算版    n皇后问题是啥我就不说了 ...

  3. [LOJ#526]「LibreOJ β Round #4」子集

    [LOJ#526]「LibreOJ β Round #4」子集 试题描述 qmqmqm有一个长为 n 的数列 a1,a2,……,an,你需要选择集合{1,2,……,n}的一个子集,使得这个子集中任意两 ...

  4. Java面试题之HashMap如何有效减少碰撞

    1.扰动函数算法,促使元素位置分布均匀,减少碰撞几率: 2.使用final对象,并采用合适的equals方法和hashCode方法:

  5. K3Cloud调用存储过程

    SQLScriptServiceHelper.GetDataFromStoredProc( this.Context, DatabaseType.Oracle, "/*dialect*/TJ ...

  6. Repeated Substrings(UVAlive 6869)

    题意:求出现过两次以上的不同子串有多少种. /* 用后缀数组求出height[]数组,然后扫一遍, 发现height[i]-height[i-1]>=0,就ans+=height[i]-heig ...

  7. 【BZOJ入门3189】 猜数字(数学,搜索)

    Description 味味最近在玩猜数字的游戏,现在她也希望你来玩一下这个游戏.猜数字游戏的规则是这样的,告诉你一个正整数 n(2<=n<=11),然后味味心中会想一个 n 个数字组成的 ...

  8. 如何在requirejs下引用bootstrap

    原本以为只要require过来就能用 require(['jquery','underscore','bootstrap','cache'],function($,U,B,C){ 但发现会报错,类似未 ...

  9. 标准C程序设计七---42

    Linux应用             编程深入            语言编程 标准C程序设计七---经典C11程序设计    以下内容为阅读:    <标准C程序设计>(第7版) 作者 ...

  10. postgresql 10 分页

    示例: select * from test limit 2 offset 2; limit:指查多少条数据 offset:从下标多少开始查,下标从0开始,不能为负数. offset计算公式: var ...