Java Web应用程序的结构? [英] Structure of Java web application?
问题描述
对不起,问这个简单的问题,我搜索了很多,我找不到一个可靠的答案,正是我想要的。这就是为什么我创建了这个问题。
Sorry to ask this simple question.I have searched a lot and I can't find a reliable answer that exactly what I want. That's why I created this question.
我们在Java中完成了两个Spring项目。
we completed two spring projects in Java.
每个项目,我们有创建,在 WebContent
中有一个不同的文件夹结构,用于模块分离。
Each project , we have created , has a different folder structure in WebContent
for module separation.
现在我们要开始一个新项目使用eclipse与SVN,该项目有三个模块。
Now we are going to start a new project using eclipse with SVN and the project has three modules.
WebContent Project One的文件夹结构,
WebContent
- moduleOne
- conf
- moduleOne.conf
- css
- moduleOne.css
- js
- moduleOne.js
- jsp
- moduleOne.jsp
- images
- moduleOne.png
- moduleTwo
- conf
- moduleTwo.conf
- css
- moduleTwo.css
- js
- moduleTwo.js
- jsp
- moduleTwo.jsp
- images
- moduleTwo.png
- META-INF
- WEB-INF
- lib
- web.xml
WebContent Project One的文件夹结构是
WebContent
- conf
- moduleOne
- moduleOne.conf
- moduleTwo
- moduleTwo.conf
- css
- moduleOne
- moduleOne.css
- moduleTwo
- moduleTwo.css
- images
- moduleOne
- moduleOne.png
- moduleTwo
- moduleTwo.png
- js
- moduleOne
- moduleOne.js
- moduleTwo
- moduleTwo.js
- jsp
- moduleOne
- moduleOne.jsp
- moduleTwo
- moduleTwo.jsp
- META-INF
- WEB-INF
- lib
- web.xml
现在我们正在选择创建文件夹结构的首选方式。
Now we are in a situation to choose the preferred way of creating a folder structure.
还应该是:
-
轻松自定义。
Easily customizable.
单独的模块,如果有任何新的要求。
Easy to modify a separate module,if any new requirement came.
任何新的想法或方法和所有答案也将不胜感激。
Any new ideas or methods and all answers would also be greatly appreciated.
推荐答案
我喜欢将静态网页资源保存在资源目录下,WEB-INF下的所有视图和配置。这样可以确保我可以在资源上启用自由访问权限和缓存。此外,这确保.jsp文件不能通过URL直接访问(除非你搞砸你的配置!)。除此之外,您的第一个解决方案是坚实的。特别是,基于相关模块的路径,更容易应用模块级安全性和其他配置。
I like to keep static web resources under a 'resources' directory and all views and config underneath WEB-INF. This ensures that I can enable liberal access permissions and caching on 'resources'. Also, this ensures that .jsp files will not be directly accessible via a URL (unless you mess up your config!). Other than that, your first solution above is solid. Especially, as it becomes easier to apply module-level security and other configuration based on the path to the relevant module.
所以作为对解决方案1的调整,我会推荐如下所示:
So as a tweak to solution 1, I would recommend something like:
- resources
- moduleOne
- css
- moduleOne.css
- js
- moduleOne.js
- images
- moduleOne.png
- moduleTwo
- css
- moduleTwo.css
- js
- moduleTwo.js
- images
- moduleTwo.png
- META-INF
- WEB-INF
- modules
- moduleOne
- conf
- moduleOne.conf
- views
- moduleOneViewOne.jsp
- moduleTwo
- conf
- moduleTwo.conf
- views
- moduleTwoViewOne.jsp
- lib
- web.xml
这篇关于Java Web应用程序的结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!