Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请指点在web.xml 中 <resource-ref>作何用场
daiwang





发贴: 60
积分: 1
于 2004-05-19 18:25 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在web.xml中把以下内容注释掉好像对程序运行没影响。我的E文不好,反复看tomcat的文档和servlet的规范文件,就是不懂在server.xml中已经申明了DataSource,为什么要在web.xml中多此一段
<resource-ref>
  <res-ref-name>
    jdbc/oracle_jw
  </res-ref-name>
  <res-type>
    javax.sql.DataSource
  </res-type>
  <res-auth>
    Container
  </res-auth>
</resource-ref>



作者 Re:请指点在web.xml 中 <resource-ref>作何用场 [Re:daiwang]
dearmeiw





发贴: 108
积分: 10
于 2004-05-19 18:36 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
这个意思就是说在你的WEB容器在会有一个JNDI名为jdbc/oracle_jw的资源可用。
换句话说就是有一个数据源可用的!



作者 Re:请指点在web.xml 中 <resource-ref>作何用场 [Re:daiwang]
slacker





发贴: 52
积分: 30
于 2004-05-19 21:50 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Any resource manager connection factory references, like
jdbc/DataSource;
jms/QueueConnectionFactory;
jms/TopicConnectionFactory;
...
There are JNDI ENV reference to your JDNI Bindings which are declared in the server.xml.
Those in the server.xml are real JNDI Bindings which are set during deployment period, and may have different setting depend on different container.
In you code, you can lookup either references set in server.xml, or JNDI ENV as "java:comp/env/jdbc/...". JNDI ENV is J2EE recommendation, can be defined during development period.

slacker.


slacker edited on 2004-05-19 21:59

作者 Re:请指点在web.xml 中 <resource-ref>作何用场 [Re:daiwang]
daiwang





发贴: 60
积分: 1
于 2004-05-19 22:27 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
web.xml中不要这一段也不影响编程和执行,而Tomcat文档中都要这一段来Declare Your Resource Requirements,这样作的目的是什么。

还有如果只在web.xml中定义这一段,server.xml中不定义,不配置。java:comp/env 中会有jdbc目录,但lookup jdbc/oracle_jw会出错,错误信息为driver为空,url为空。从这个效果来看,好像这一段的作用不只是Declare Your Resource Requirements了



作者 Re:请指点在web.xml 中 <resource-ref>作何用场 [Re:daiwang]
Geminist





发贴: 45
积分: 50
于 2004-05-21 18:25 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
server.xml中要先定义才行啊,web.xml中只是起一个引用的作用。这个关系就好像object和reference的关系


作者 Re:请指点在web.xml 中 <resource-ref>作何用场 [Re:daiwang]
tintin365



发贴: 0
积分: 0
于 2004-06-03 09:06 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
最好不要在web。xml中配置这个,配了这个反而容易引起问题



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923