我正在将netbeans 6.9.1与Glassfish 3一起使用,以创建由少量servlet组成的Web应用程序。
我需要在配置文件中为数据库连接字符串存储一个值。
据我所知,这是使用web.xml文件(sun-web.xml是自动生成的文件)完成的:
<context-param>
<param-name>connectionString</param-name>
<param-value>connection string value in here</param-value>
然后在servlet init()期间使用读取
String conString = context.getInitParameter("connectionString");
但是,当netbeans部署应用程序时,出现以下错误
SEVERE: DPL8007: Invalid Deployment Descriptors element param-name value connectionString SEVERE: DPL8007: Invalid Deployment Descriptors element param-value valu
知道我在这里做错了吗?这是文件的完整内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app error-url="">
<context-param>
<param-name>connectionString</param-name>
<param-value>Con value</param-value>
</context-param>
<context-root>/FQEX</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</sun-web-app>
提前致谢。
最佳答案
我在<context-param>
DTD中看不到sun-web.xml
。因此,我猜您不应该在那儿这样做。将此放置在常规web.xml
中,它将在此处正常工作。