[英]how to add db directory to web.xml
I have a java web app configured with apache v9.0 and eclipse IDE. 我有一个配置了apache v9.0和eclipse IDE的Java Web应用程序。 What I need is to keep my database in
C:\\db
so It cannot be access directly from outside and should be away from my webapp project directory. 我需要将数据库保存在
C:\\db
这样它就不能直接从外部访问,而应该远离我的webapp项目目录。 What I don't is how to let my web app know that if a user request for a file it should go and check it in my C:\\db
and reply back with the file. 我不想要的是如何让我的Web应用程序知道,如果用户请求文件,则应去我的
C:\\db
文件中检查它,然后用文件答复。
Based in my research, some was saying to specify my directory in my webapp web.xml file and others was saying I need to specify it in my tomcat/conf/server.xml file. 根据我的研究,有人说要在我的webapp web.xml文件中指定目录,而有人说我需要在tomcat / conf / server.xml文件中指定目录。
I'd really appreciate if somebody tell me what to do? 如果有人告诉我该怎么办,我将不胜感激。
Try adding your database path C:\\db
as JVM argument
and accessing it in application. 尝试将数据库路径
C:\\db
为JVM argument
,然后在应用程序中访问它。 you may try this as two ways either set as system property and access when it required or set as JVM argument and access it. 您可以通过两种方法尝试将其设置为系统属性并在需要时进行访问,或者设置为JVM参数并对其进行访问。
SetSystemProperties
SetSystemProperties
System.setProperty("database", "C:\\\\db"); . . access it as and when required String databasepath= System.getProperty("database");
Setting as JVM Arguments.
设置为JVM参数。
-Ddatabase="C:\\db"
-D
is placed in front of each system property that we are passing in as a VM argument, and following this is an equal sign
followed by the value of that system property
. -D
放在我们作为VM参数传入的每个系统属性的前面,其后是equal sign
后跟该system property
的值。 String databasepath= System.getProperty("database");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.