蚀动态Web项目文件位置 [英] eclipse dynamic web project file locations

查看:43
本文介绍了蚀动态Web项目文件位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Eclipse中创建一个新的动态Web项目,并且想知道文件夹分类法的最佳实践是什么.我认为这是<>文件夹.有人可以验证吗?

I'm creating a new dynamic web project in Eclipse and was wondering what best practices are for folder taxonomy. Here's what I believe it is <> are folders. Can someone please verify?

 <Eclipse project name>
    <src>
        -- .java files
    <WebContent> 
        -- .html pages
        <images> 
        <css> 
        <js>
        <META-INF> 
            MANIFEST.MF 
        <WEB-INF> 
            web.xml
        <app name>
          -- .jsp pages 

推荐答案

以下是动态Web项目的示例文件夹结构:

Here is a sample folder structure of a dynamic web project:

如您所见,所有静态文件都作为子文件夹放置在 WebContent 文件夹下.通过命名约定,.css文件位于 css 子文件夹中. JavaScript .js文件放置在 js 子文件夹下,任何图像文件(例如.jpeg或.png)都放置在 images 子文件夹下.我还有一个额外的 lib 子文件夹,在其中放置了要使用的angularjs库.

As you can see all static files are placed as sub-folders under the WebContent folder. By naming conventions .css files are places in the css sub-folder. JavaScript .js files are placed under the js sub-folder and any image files such as .jpeg or .png are placed in the images sub-folder. I also have an extra lib sub-folder where I placed an angularjs library to be used.

默认情况下,创建动态Web项目后,您的web.xml文件如下所示:

By default after creation of a dynamic web project your web.xml file looks like so:

 `<welcome-file-list>
 <welcome-file>index.html</welcome-file>
 <welcome-file>index.jsp</welcome-file>`

表示在运行应用程序时它将首先调用列出的默认名称文件.这就是为什么大多数项目将文件命名为 index.html index.jsp 的原因. 注意:我的index.html文件位于WebContent文件夹正下方,而不位于子文件夹中

meaning it will first call the listed default name files when you run your application. This is why most projects will name the files as index.html or index.jsp. NOTE: that my index.html file is directly below the WebContent folder and not in a sub-folder

最后,您可以像下面这样从'index'文件调用/包含您的静态文件(.css .js和图像文件):

Finally you can call/include your static files (.css .js and image files) from your 'index' file like so:

    <link rel="stylesheet" href=css/bootstrap.min.css>
    <link rel="stylesheet" href=css/bootstrap-theme.min.css>

    <script type="text/javascript" src="lib/angular.min.js"></script>
    <script src="js/contactsApp.js"></script>

您的.java文件也将正确放入 Java资源-> src -> {将Java文件放在此处}

Also your .java files will properly go in the Java Resources -> src -> {place java files here}

这篇关于蚀动态Web项目文件位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆