当前位置: 首页 > news >正文

Eclipse Java EE IDE 创建 Dynamic Web project问题

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Eclipse Java EE IDE for Web Developers 创建的 Dynamic Web project 编译后的class文件默认存放路径问题,默认存放路径是build/classes导致应用部署后,Tomcat 抛出异常:

<!-- lang: java -->
The value for the useBean class attribute XXX is invalid

Java Servlet 3.0 Specification(java Servlet 3.0 规范是这样描述的)

10.5 Directory Structure A Web application exists as a structured hierarchy of directories. The root of this hierarchy serves as the document root for files that are part of the application. For example, for a Web application with the context path /catalog in a Web container, the index.html file at the base of the Web application hierarchy or in a JAR file inside WEB-INF/lib that includes the index.html under META-INF/resources directory can be served to satisfy a request from /catalog/index.html. If an index.html is present both in the root context and in the META-INF/resources directory of a JAR file in the WEB-INF/lib directory of the application, then the file that is available in the root context MUST be used. The rules for matching URLs to context path are laid out in Chapter 12, “Mapping Requests to Servlets”. Since the context path of an application determines the URL namespace of the contents of the Web application, Web containers must reject Web applications defining a context path that could cause potential conflicts in this URL namespace. This may occur, for example, by attempting to deploy a second Web application with the same context path. Since requests are matched to resources in a case-sensitive manner, this determination of potential conflict must be performed in a case-sensitive manner as well. A special directory exists within the application hierarchy named “WEB-INF”. This directory contains all things related to the application that aren’t in the document root of the application. Most of the WEB-INF node is not part of the public document tree of the application. Except for static resources and JSPs packaged in the META- INF/resources of a JAR file that resides in the WEB-INF/lib directory, no other files contained in the WEB-INF directory may be served directly to a client by the container. However, the contents of the WEB-INF directory are visible to servlet code using the getResource and getResourceAsStream method calls on the ServletContext, and may be exposed using the RequestDispatcher calls. Hence, if the Application Developer needs access, from servlet code, to application specific configuration information that he does not wish to be exposed directly to the Web client, he may place it under this directory. Since requests are matched to resource mappings in a case-sensitive manner, client requests for ‘/WEB-INF/foo’, ‘/WEb- iNf/foo’, for example, should not result in contents of the Web application located under /WEB-INF being returned, nor any form of directory listing thereof. The contents of the WEB-INF directory are: ■ The /WEB-INF/web.xml deployment descriptor. ■ The /WEB-INF/classes/ directory for servlet and utility classes. The classes in this directory must be available to the application class loader. ■ The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain servlets, beans, static resources and JSPs packaged in a JAR file and other utility classes useful to the Web application. The Web application class loader must be able to load classes from any of these archive files. The Web application class loader must load classes from the WEB-INF/classes directory first, and then from library JARs in the WEB-INF/lib directory. Also, except for the case where static resources are packaged in JAR files, any requests from the client to access the resources in WEB-INF/ directory must be returned with a SC_NOT_FOUND(404) response.

** 规范的定义:服务器的class loader类加载器默认加载 /WEB-INF/classes目录下的 *.class文件 **

**1** 在创建 Dynamic Web project 时,就可以设置*.class文件的输出存放目录:

File>new > Dynamic Web project > next > 在default output folder地方的"build/classes"改成"WEB-INF\classes" > finish就可以了 2 如果在创建的时候忘记更改的话: 可以右击项目>build path > configure build path > 选择 source选项,将default output folder地方的"build/classes"改成"WebContent/WEB-INF/classes" > finish就可以了

转载于:https://my.oschina.net/artshell/blog/184459

相关文章:

  • 集成第三方接口的技巧总结
  • 开始VS 2012 中LightSwitch系列的第2部分:感受关爱——定义数据关系
  • 在左上角倾斜四十五度显示的TextView
  • java IO类简单介绍
  • 高新集训记录
  • css控制大幻灯绝对居中(非背景)
  • Java synchronized用法
  • Zuul小技巧 /routes
  • flex 与 javascript互调用
  • vue2的keep-alive的总结
  • 一款轻量的图像缩放插件
  • class与dex文件
  • 嵌入式Linux:基于ARM11下Android应用点亮LED灯 【PDF版论文下载】
  • 11.24 静态元素过期时间
  • AWS的登录认证。。。
  • ES2017异步函数现已正式可用
  • Fundebug计费标准解释:事件数是如何定义的?
  • JavaScript实现分页效果
  • Linux编程学习笔记 | Linux多线程学习[2] - 线程的同步
  • MQ框架的比较
  • python3 使用 asyncio 代替线程
  • React中的“虫洞”——Context
  • scala基础语法(二)
  • session共享问题解决方案
  • tensorflow学习笔记3——MNIST应用篇
  • Vue 动态创建 component
  • 个人博客开发系列:评论功能之GitHub账号OAuth授权
  • 利用jquery编写加法运算验证码
  • 猫头鹰的深夜翻译:Java 2D Graphics, 简单的仿射变换
  • 前端技术周刊 2019-02-11 Serverless
  • 系统认识JavaScript正则表达式
  • 一个SAP顾问在美国的这些年
  • 追踪解析 FutureTask 源码
  • ​软考-高级-系统架构设计师教程(清华第2版)【第15章 面向服务架构设计理论与实践(P527~554)-思维导图】​
  • # centos7下FFmpeg环境部署记录
  • #我与Java虚拟机的故事#连载16:打开Java世界大门的钥匙
  • (1综述)从零开始的嵌入式图像图像处理(PI+QT+OpenCV)实战演练
  • (C#)一个最简单的链表类
  • (Matalb回归预测)PSO-BP粒子群算法优化BP神经网络的多维回归预测
  • (solr系列:一)使用tomcat部署solr服务
  • (黑马C++)L06 重载与继承
  • (简单有案例)前端实现主题切换、动态换肤的两种简单方式
  • (免费领源码)python#django#mysql公交线路查询系统85021- 计算机毕业设计项目选题推荐
  • (算法设计与分析)第一章算法概述-习题
  • (转)Scala的“=”符号简介
  • ..回顾17,展望18
  • .NET 5种线程安全集合
  • .NET CORE 3.1 集成JWT鉴权和授权2
  • .NET delegate 委托 、 Event 事件,接口回调
  • .net Stream篇(六)
  • .net反混淆脱壳工具de4dot的使用
  • .NET和.COM和.CN域名区别
  • .net实现客户区延伸至至非客户区
  • .vollhavhelp-V-XXXXXXXX勒索病毒的最新威胁:如何恢复您的数据?
  • /deep/和 >>>以及 ::v-deep 三者的区别