`

Only a type can be imported

    博客分类:
  • java
阅读更多
<!--StartFragment -->

一个小项目移到服务器上,发现以前的项目出错了,访问一个很简单的jsp也会报错,说无法编译,报的错误就是:Only a type can be imported. com.xxx.xxx.XXX resolves to a package,意思就是说你jsp页面上引用的那个类不存在,可是测试的时候却正常,其实这样JSP已经是访问到的了,只是找不到类,我想应该是路径有问题,是的,因为放在服务器中,为了方便管理,服务器管理员建多了个子目录,而tomcat的context没有改变,每一个子文件夹都会被tomcat当作一个独立的虚拟应用的,所以每个子文件夹下的jsp页面访问的时候,都会在它的同一层找WEB-INF里面的class,这样当然找不到了,只有刚巧放在根目录下的jsp文件能访问。

解决办法:

<Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
    <Context path="/MyLab2/MyLab" docBase="D:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\MyLab2\\MyLab" reloadable="true">
    </Context>
      </Host>

只要加多这个context就可以了,其中path为访问路径,docBase为项目文件根目录所在。这样应用的文件路径通过docBase来指定,这样就不会再产生找不到class的问题了。

 

分享到:
评论

相关推荐

    javamail的jar包

    不导入mail.jar会发生 An error occurred at line: 6 in the generated java file Only a type can be imported. javax.mail.Session resolves to a package

    Some projects cannot be imported because they already exist in the workspace

    有时候eclipse或者myeclipse导入项目的时候会发生上面两个错误,IDE不允许我们导入。具体原因是在IDE的workspace中已经存在了相同名字的项目,所以不能导入。

    A class to hook any imported function call made by your app

    A class to hook any imported function call made by your app监视输入函数的类

    Code Warehouse Personal Edition v1.0

    A complete application or a class can be easily imported into Code Warehouse. Code stored in Code Warehouse can be searched by keywords, authors, dates, names of code units (application, class, or ...

    JSP Simple Examples

    and one of the feature of OOP in java is that, we can assign a subclass object or variable to the variable of the superclass type. Log files Log files keeps a records of internet protocol addresses...

    ExactAudioCopy_1.0_Beta1_XiaZaiBa.exe

    + New database engine for storing CD information (old databases can be imported) + Metadata plugin support, for now there is a freedb plugin included. This will be released as open source freeware ...

    DjVu的阅读软件!!!!!!!!!!

    Source images can be imported into DjVuer directly from a TWAIN scanner, or loaded from common file formats such as JPEG files and Windows bitmap files. These images can then be converted and saved as...

    语音识别系统C#实例

    A large number of Hypothesis events will be generated while only one Recognition and EndStream events will be associated with a particular recognition attempt. The sample provides a standard file ...

    StraceNT v0.8(strace on Windows)

    It can trace all the calls made by a process to the imported functions from a DLL. StraceNT can be very useful in debugging and analyzing the internal working of a program. StraceNT uses IAT patching...

    Strace for Windows

    It can trace all the calls made by a process to the imported functions from a DLL. StraceNT can be very useful in debugging and analyzing the internal working of a program. StraceNT uses IAT patching...

    Crystal Impact Match!2.1.3 试用延长

    In addition to this qualitative analysis, a quantitative analysis (using Rietveld refinement) can be performed as well. You can easily setup and run Rietveld refinements from within Match!, with the ...

    UnityShader使用Shader将图片进行水平/竖直镜像翻转

    Resource type: Unitypackage, can be imported and used immediately Content: Including shaders, materials, and sample scenes It is possible to autonomously mirror and flip graphics horizontally or ...

    DE2官方文件-DE2_synthesizer

    can be re-used. To perform a clean compilation from source files for all partitions, both the db and incremental_db folder should be removed. The imported_partitions sub-folder contains the last ...

    免费的汽车仿真开发环境 TSMaster V2021.8.3.600

    [10] New: calibration parameters can be imported from hex [11] New: buttons on quick customization bar on main ribbon [12] Bug fix: panel input-output box initial value is always n.a. [13] Bug fix: ...

    Android代码-DNSQuery

    This is a free tool provided for the Android mobile platform by Comwired.com to ...Everything should be included to be easily imported into the Eclipse IDE and has been developed to build on

    在excel中打印日历的vba宏。

    This is a piece of VBA Macro code can be imported into MS Excel, successfully running on Excel 2010.

    Imported dd.rar

    Imported dd.rar

    03Vuforia图片识别超详细案例(小岛动画交互)素材

    Vuforia Engine can be easily imported into Unity by downloading and double-clicking the .unitypackage below.Vuforia Engine is the most widely used platform for AR development, with support for the ...

    TX SDK 3.08.1.0

    Linestyles can be imported from Bentley® MicroStation® .dgn files into .dwg files. For more details, see Working with DGN Linestyles. Strikethrough text Multi-line text now supports strikethrough ...

    2008年6月大学英语六级A卷真题

    such as a kidney, the surgeon would contact a commercial organ producer, give him the patient’s immunological profile and would then be sent a kidney with the correct tissue type. These organs ...

Global site tag (gtag.js) - Google Analytics