项目导入时报错:The import javax.servlet.http.HttpServletRequest cannot be resolved 解决方法
Error:
The import javax.servlet cannot be resolved
The import javax.servlet.http.HttpServletRequest cannot be resolved
Description:
遇到这样的错误,如果东西都安装的全的话,按照下面的步骤就可以了
我们经常会把别人的项目copy到自己这里进行二次开发或者参考,有的时候会发生上面的错误,
即eclipse项目里我们导入的项目里提示HttpServletRequest 不能引用,会伴随头疼的小红叉出现。
Accuse:
具体原因是我们工程里面web-inf/lib目录下少了相应的包:Package javax.servlet.http引起的;
通俗且确切的讲就是缺少TOMCAT_HOME\lib下的servlet-api.jar。
我导入别人的项目,在别人的机器上他配置了Server,一般都是tomcat,而在拷贝的过程中Server的那些library是不会随项目一起拷贝过来的,除非别人把tomcat的library已经拷贝到WEB-INF\lib下了。
Action:
Project -> Properties -> Java Build Path -> Add Library -> Server Runtime -> next -> 选择你的Server -> Finish
http://blog.csdn.net/shubingzhuoxue/article/details/52385854
如果在上面打开目录的时候没有找到Server Runtime,那就看下面
eclipse针对不同的项目类型有不同的版本,下载地址: http://www.eclipse.org/downloads/index-developer.php
当用android版的开发web时,会出现windows->preferences选项中(server)缺失, 解决方法如下:
- 方法一:
找到Help->InstallNew Software->”Kepler” repository(http://download.eclipse.org/releases/kepler)->Web,XML, Java EE and OSGi Enterprise Development ->JST Server AdaptersExtensions(打勾选上该项)
然后一路NEXT 完成安装
如图:
安装完成后,server选项就有了,如图
后面就可以按照网上常规知道配置Tomcat了
方法二:
到 http://www.eclipse.org/downloads/index-developer.php 上下载jJ2EE版本即可.
http://blog.csdn.net/keebai/article/details/52752870
如果在执行第二个的时候遇到一些问题?
例如
The Apache Tomcat installation at this directory is version 8.5.6A Tomcat 8.0 installation is expect
这样的问题。。。。。。
是不是感觉很坑(o(╥﹏╥)o)
解决办法:
Windows中
①在Tomcat的安装目录中找到lib目录,再找到catalina.jar。使用压缩软件(WinRAR或是好压)打开它。
②依次找到并双击打开org\apache\catalina\util\ServerInfo.properties 文件
server.info=Apache Tomcat/8.5.6
server.number=8.5.6.0
server.built=Oct 6 2016 20:15:31 UTC
改为:
#Apache Tomcat/8.5.6
server.info=Apache Tomcat/8.0.0
#8.5.6.0
server.number=8.0.0
server.built=Oct 6 2016 20:15:31 UTC
在Linux中改法:
cd [tomcat or tomee home(tomcat目录)]/lib
mkdir catalina
cd catalina/
unzip ../catalina.jar
vim org/apache/catalina/util/ServerInfo.properties
- 把版本号改成如下形式
server.info=Apache Tomcat/8.0.0
server.number=8.0.0
server.built=May 11 2016 21:49:07 UTC
接着把改好的ServerInfo.properties文件添加到catalina.jar中:
jar uf ../catalina.jar org/apache/catalina/util/ServerInfo.properties
cd ..
rm -rf catalina
Linux改法我没有实践,不过我是参照Linux的改法在Windows上操作的,所以应该不会错!
其他版本要是也报这样的错,改法是一样的!
参考地址:
http://stackoverflow.com/a/37614406/6952713
项目导入时报错:The import javax.servlet.http.HttpServletRequest cannot be resolved 解决方法的更多相关文章
- 在Myeclipse buildpath 加server lib (server runtime)/项目导入时报错:The import javax.servlet.http.HttpServletRequest cannot be resolved
来源于:http://blog.csdn.net/dingqinghu/article/details/8805922 http://yl-fighting.iteye.com/blog/140946 ...
- 项目导入时报错:The import javax.servlet.http.HttpServletRequest cannot be resolved
Error: The import javax.servlet cannot be resolved The import javax.servlet.http.HttpServletRequest ...
- The import javax.servlet.http.HttpServletRequest cannot be resolved
Error: The import javax.servlet cannot be resolved The import javax.servlet.http.HttpServletRequest ...
- The import javax.servlet.jsp.JspException cannot be resolved
问题描述 重新更换了 Apache Tomcat 的版本,在 Eclipse 中项目报错信息:The import javax.servlet.jsp.JspException cannot be ...
- 编译时提示软件包 javax.servlet.http 不存在 import javax.servlet.http.HttpServletRequest;
编译时错误:软件包 javax.servlet.http 不存在import javax.servlet.http.HttpServletRequest; 解决办法:把servlet-api.jar加 ...
- The type javax.servlet.http.HttpServletRequest cannot be resolved.
The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from ...
- java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z 的解决
jetty 9 嵌入式开发时,启动正常,但是页面一浏览就报错如下: java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest ...
- 使用maven创建项目时报错The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
Description Resource Path Location Type The superclass "javax.servlet.http.HttpServlet" wa ...
- [spring]启动时报错:NoSuchMethodError: javax.servlet.http.HttpServletResponse.getStatus()I
Spring V4.1以后的版本在不支持Servlet3.0的应用服务器上跑时会报如下错误: NoSuchMethodError: javax.servlet.http.HttpServletResp ...
随机推荐
- css特效博客
1. 前端网上: e344657992 http://www.qdfuns.com/notes/15477/02cb463c28d9fe69ee0bc804448b8316.html
- Virtualbox主机和虚拟机之间文件夹共享及双向拷贝
把文件发到VirtualBox的方法有很多,下面推荐两种: 1.把要共享的文件夹挂载到虚拟机某一个文件上: (1)打开虚拟机的设置,点击左边的“共享文件夹”,点击带加号的文件按钮,在文件夹路径选择要共 ...
- LeetCode--006--Z字型变换(java)
将一个给定字符串根据给定的行数,以从上往下.从左到右进行 Z 字形排列. 比如输入字符串为 "LEETCODEISHIRING" 行数为 3 时,排列如下: L C I R E T ...
- 最新的vueWebpack项目
最近优化了我的vueWebpack多入口框架,感觉清新了好多:http://pan.baidu.com/s/1bNYJp0
- laravel调度任务
<?php namespace App\Console; use Illuminate\Console\Scheduling\Schedule;use Illuminate\Foundation ...
- CentOS7 安装Nginx 1.14:
nginx-1.14.2.tar.gz:下载:wget http://nginx.org/download/nginx-1.14.2.tar.gz 安装nginx: yum install ...
- 反射API(一)
<?php function classData(ReflectionClass $class) { echo '<hr>'; $details = '当前文件:'; $detail ...
- 4.1.6 Grundy数-硬币游戏2
Problem Description: Alice 和 Bob 在玩一个游戏.给定 k 个数字 a1,a2,……,ak.一开始,有n堆硬币,每堆各有 Xi 枚硬币.Alice 和 Bob 轮流选出一 ...
- Fragment的onCreateView和onActivityCreate之间的区别(转)
看了有关这个问题的几篇博文,几乎都是引用了stackoverflow上的一个回答: 问题: I know that a fragment’s view hierarchy has to be infl ...
- poj-1061-exgcd
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 128285 Accepted: 27962 Descript ...