加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Eclipse Dynamic Web Project如何组织文件?

发布时间:2020-12-15 04:45:20 所属栏目:Java 来源:网络整理
导读:所以我正在学习Web应用程序开发,我对如何在 eclipse for Dynamic Web Application提供的模板中组织我的文件感到困惑. 我应该将我的HTML页面放在WebContent中吗?我在哪里放置JSP和servlet源文件?全球遵循什么样的惯例? 这是eclipse提供的模板结构 部署描述
所以我正在学习Web应用程序开发,我对如何在 eclipse for Dynamic Web Application提供的模板中组织我的文件感到困惑.

我应该将我的HTML页面放在WebContent中吗?我在哪里放置JSP和servlet源文件?全球遵循什么样的惯例?

这是eclipse提供的模板结构

>部署描述符
> JavaScript资源

> WebContent
> ECMAScript内置库
> ECMA 3浏览器支持库

> src
> JRE系统库
> Apache Tomcat v8
> Web App库
> EAR图书馆
>构建
> WebContent

> META-INF
> WEB-INF

> lib

解决方法

将HTML和JSP页面放在WebContent目录中.

Eclipse帮助页面referenced by android-weblineindia声明WebContent是:

The mandatory location of all Web resources,including HTML,JSP,graphic files,and so on. If the files are not placed in this directory (or in a subdirectory structure under this directory),the files will not be available when the application is executed on a server. The Web content folder represents the contents of the WAR file that will be deployed to the server. Any files not under the Web content folder are considered development-time resources (for example,.java files,.sql files,and .mif files),and are not deployed when the project is unit tested or published.

所以浏览器所需的CSS文件和JS文件也应该放在这里.

将java源文件(包括servlet源)放在src目录中.相同的帮助页面为源目录指出了这一点(虽然它表明它被称为JavaSource,看起来像文档中的错误):

Contains the project’s Java source code for classes,beans,and servlets. When these resources are added to a Web project,they are automatically compiled and the generated files are added to the WEB-INF/classes directory. The contents of the source directory are not packaged in WAR files unless an option is specified when a WAR file is created.

如果你看项目属性 – >部署程序集您应该看到从src编译的文件部署到WEB-INF / classes,WebContent中的文件部署到WAR文件的根目录

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读