我有一个共同财产调查网站,而不是春天的MVC网站,它有一个汇辑网站。
在我喜欢查阅的网上xml档案中有若干种环境。
然而,我想从我的成套资料中选取一个班子,进入这些场所。
我知道,我可以把SerletContect从联合人民军转至这几类人,但我想避免这种情况,只是从我的班子上查阅网页。
这是可能的吗?
http://www.ohchr.org。
我一直在研究<代码>javax.servlet。 我想到的是我所希望的,但如果我看不到。
我有一个共同财产调查网站,而不是春天的MVC网站,它有一个汇辑网站。
在我喜欢查阅的网上xml档案中有若干种环境。
然而,我想从我的成套资料中选取一个班子,进入这些场所。
我知道,我可以把SerletContect从联合人民军转至这几类人,但我想避免这种情况,只是从我的班子上查阅网页。
这是可能的吗?
http://www.ohchr.org。
我一直在研究<代码>javax.servlet。 我想到的是我所希望的,但如果我看不到。
使用javax.servlet.ServletContextListener 执行,使单一州类人能够进入环境:
package test.dummy;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
public class ContextConfiguration implements ServletContextListener {
private static ContextConfiguration _instance;
private ServletContext context = null;
//This method is invoked when the Web Application
//is ready to service requests
public void contextInitialized(ServletContextEvent event) {
this.context = event.getServletContext();
//initialize the static reference _instance
_instance=this;
}
/*This method is invoked when the Web Application has been removed
and is no longer able to accept requests
*/
public void contextDestroyed(ServletContextEvent event) {
this.context = null;
}
/* Provide a method to get the context values */
public String getContextParameter(String key) {
return this.context.getInitParameter(key);
}
//now, provide an static method to allow access from anywere on the code:
public static ContextConfiguration getInstance() {
return _instance;
}
}
在网上设立:
<web-app>
<listener>
<listener-class>
test.dummy.ContextConfiguration
</listener-class>
</listener>
<servlet/>
<servlet-mapping/>
</web-app>
在法典中从任何地方使用:
ContextConfiguration config=ContextConfiguration.getInstance();
String paramValue=config.getContextParameter("parameterKey");
Hmmm. 我假定,一旦您的网页上台,你将不改变网站。
现在,你可以做的是建立一个装饰器,装上一个单一吨级。 您可在您的网页上使用以下术语。
<servlet>
<description></description>
<display-name>XMLStartUp</display-name>
<servlet-name>XMLStartUp</servlet-name>
<servlet-class>com.test.servlets.XMLStartUp</servlet-class>
<init-param>
<param-name>log4j-init-file</param-name>
<param-value>WEB-INF/classes/log4j.properties</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
在目录中,如果你制定<代码>上载-启动<>代码/代码>数值0
,则这意味着在装上该编码时,其优先权最高。 现在,在服务器中<代码>init 方法中,读到所有像样的内分参数,并将其放入你的单子类别。
String dummy= getInitParameter("log4j-init-file");
这并非易事,可能不是一个ele切的解决办法。 我可以建议的唯一选择是,在您的WEB-INF/级名录中找到您的配置选择,即Xml或特性档案,以便你能够使用<条码>查询。
我知道,这可能是组合的重复,但海事组织的热情方式。
I really don t like classes reading from web.xml... Why do you need that? IMHO it would be easier, cleaner and by far much more manageable if you prepared a properties file and a manager class that reads from there.
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...