java-为什么需要在Server.xml中而不是web.xml中设置领域设置
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java-为什么需要在Server.xml中而不是web.xml中设置领域设置,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2477字,纯文字阅读大概需要4分钟。
内容图文
我正在研究Java应用程序一段时间.我主要在.NET平台上工作.尽管我觉得这两个平台之间有很多共同的概念,但是在很少的地方可以找到一些与配置有关的问题.
我正在研究身份验证和授权,并认为可以获得与JAVA中的.NET成员资格API类似的东西.我最近得到的是使用j_security_check.我还了解了JAAS,但认为对我来说太深了.
我已经在数据库中创建了用户表和角色表,现在我必须在某处指定JDBC Realm设置.我正在使用Tomcat 7.0.在大多数地方,都提到我需要在server.xml中指定领域设置,但这不适用于该服务器上部署的所有Web应用程序,因为它将成为服务器级配置?
在一个网站上,我什至看到开发人员提到了context.xml,但是再也看不到一个标准文档,该文档提到了使用此XML文件设置JDBC领域
在.NET中,我们始终将成员资格设置放在web.config级别,而不是Machine.config.
对此完全困惑.寻找一些光.
解决方法:
Why is Realm setting required in Server.xml and not web.xml
这是不正确的,您也可以在webapp中定义它,但是只能在servlet容器特定的配置文件中定义,例如对于Tomcat,则是/META-INF/context.xml.无法在/WEB-INF/web.xml中定义它,因为它特定于标准Servlet API,而不是servletcontainer实现.
But wouldn’t that apply to all web application deployed on that server since it would become a server level configuration ?.
没错如果您无法控制服务器或不想通过其他Web应用程序发布领域,则不建议这样做.
On a site I even saw a developer mentioning about context.xml but again can’t see a standard document that mention about using this XML file for setting JDBC realm
您可以在webapp的/META-INF/context.xml中指定它.另请参见Tomcat’s own documentation on the <Context> element:
Defining a context
It is NOT recommended to place
<Context>
elements directly in theserver.xml
file. This is because it makes modifying the Context configuration more invasive since the mainconf/server.xml
file cannot be reloaded without restarting Tomcat.Individual Context elements may be explicitly defined:
In an individual file at
/META-INF/context.xml
inside the application files. Optionally (based on the Host’s copyXML attribute) this may be copied to$CATALINA_BASE/conf/[enginename]/[hostname]/
and renamed to application’s base file name plus a “.xml” extension.In individual files (with a “.xml” extension) in the
$CATALINA_BASE/conf/[enginename]/[hostname]/
directory. The context path and version will be derived from the base name of the file (the file name less the .xml extension). This file will always take precedence over any context.xml file packaged in the web application’s META-INF directory.Inside a 07001 element in the main
conf/server.xml
.
(重点不是我的,它已经在Tomcat的文档中这样)
内容总结
以上是互联网集市为您收集整理的java-为什么需要在Server.xml中而不是web.xml中设置领域设置全部内容,希望文章能够帮你解决java-为什么需要在Server.xml中而不是web.xml中设置领域设置所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。