今天我从码云上拉一个项目下来,是个maven项目,闲来无事自己研究研究,发现刚拉下来,项目就有报错,我一看是httpServletRequest cannot be resolved to a type, 应该是少了servlet的jar包,直接在pom.xml中添加了这个servlet的依赖,这个依赖的域范围要改成provided 即:

 <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>

发现错误变成了标题上的两个错误,这两个错误都是没有jsp的jar包导致的,我果断再加了一个依赖:

 <dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>

这样就不报错了,项目正常启动,第一次我这个jsp-api的域范围没有设置为provided,启动项目就报错

报的是:

 Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/mybatisplus-spring-mvc]]

然后我改了jsp-api的作用域就ok了,这里解释下为什么要将这两个依赖的作用域设置为provided,这是因为我使用的是maven内置的tomcat插件启动的项目,而tomcat本身就

自带了这两个jar包,如果你设置为默认的,会将这两个jar包打包进去,就会造成重复,和Tomcat里自带的相冲突。

大家看一下就明白了

当然如果你使用的是maven内置的插件jetty的话,就不用设置这个域的范围!

解决方法二:

  选择你的项目,右击build path -》Config Build Path..  ->libraries->Add External JARS..

  然后选择你本机器上的Tomcat,选择它里面的jsp-api.jar

  然后一路确定就可以了。

如有不对的地方,欢迎指正!

javax.servlet.jsp.JspException cannot be resolved to a type 和 javax.servlet.jsp.PageContext cannot be resolved to a type 解决办法的更多相关文章

  1. javax.servlet.jsp.JspException cannot be resolved to a type

    javax.servlet.jsp.PageContext cannot be resolved to a type javax.servlet.jsp.JspException cannot be ...

  2. The import javax.servlet.jsp.JspException cannot be resolved

    问题描述   重新更换了 Apache Tomcat 的版本,在 Eclipse 中项目报错信息:The import javax.servlet.jsp.JspException cannot be ...

  3. 报错:javax.servlet.jsp.PageContext cannot be resolved to a type;javax.servlet.jsp.JspException cannot be resolved to a type

    Multiple annotations found at this line: - javax.servlet.jsp.PageContext cannot be resolved to a typ ...

  4. jsp 页面 javax.servlet.jsp.JspException cannot be resolved to a type 异常

    <dependencies><dependency><groupId>javax.servlet</groupId><artifactId> ...

  5. js页面报错javax.servlet.jsp.PageContext cannot be resolved to a type解决

    构建了一个maven项目但是项目创建好的jsp总会报错javax.servlet.jsp.PageContext cannot be resolved to a type,但是不影响项目运行.但总归难 ...

  6. jsp&servlet报红线javax.servlet.jsp.XXXX cannot be resolved to a type类似错误解决办法

    javax.servlet.jsp.JspException cannot be resolved to a type javax.servlet.jsp.PageContext cannot be ...

  7. maven中解决javax.servlet.jsp.PageContext cannot be resolved to a type

    在eclipse环境下用maven出现:javax.servlet.jsp.PageContext cannot be resolved to a type. 这是由于没有引入jsp-api引发的问题 ...

  8. 错误:javax.servlet.jsp.PageContext can not be to a type

    在写Jsp文件时,引入script源文件(<script type="text/javascript" src="${pageContext.request.con ...

  9. JSP中的9大内置对象四大域与servlet里的三大域

    九大内置对象 隐式对象 说明 out 转译后对应JspWriter对象,其内部关联一个PringWriter对象 request 转译后对应HttpServletRequest/ServletRequ ...

  10. javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/el/ELResolver错误解决办法

    今天不用eclipse.myeclipse等开发工具,纯手写JSP页面(有点作死)时突然出现以前从来没遇到过的问题,报错如下: HTTP Status 500 - java.lang.NoClassD ...

随机推荐

  1. socket编码问题

    server.py import socket ip_port = ('127.0.0.1',9999) sk = socket.socket() sk.bind(ip_port) sk.listen ...

  2. 如何通过sequel pro导入.sql脚本

    1.参考地址     https://zhidao.baidu.com/question/985373253463808219.html

  3. NewtonSoft.Json NULL转空字符串

    from:http://www.cnblogs.com/hetuan/articles/4565702.html NewtonSoft.Json对需要转为JSON字符串的对象的NULL值以及DBNul ...

  4. Retrofit学习笔记(一)

    github上的介绍,简单明了 Type-safe HTTP client for Android and Java by Square, Inc. http://square.github.io/r ...

  5. hfut 1287

    http://acm.hfut.edu.cn/OnlineJudge/ 中文题. 区间线段树,需要剪枝.n的大小有问题. #include <iostream> #include < ...

  6. csu1326(The contest)

    题目链接:传送门 题目思路:并查集加分组背包 #include <iostream> #include <cstdio> #include <cstdlib> #i ...

  7. 距离,margin padding ,width height 用法 ,记录

    margin:0 auto 表示什么意思 margin后面如果只有两个参数的话,第一个表示top和bottom,第二个表示left和right 因为0 auto,表示上下边界为0,左右则根据宽度自适应 ...

  8. debug_backtrace final catch

    <?php function backtrace_str(){ $str = ''; $w = 0; $backtrace = debug_backtrace(); foreach($backt ...

  9. git database 数据库 平面文件

    w 各个分支  git init 数据库 master分支 git 数据库 “分布式 地位平等的 ”  “git 区别与svn,没有 c/s 主从的概念”“”“c/s” 大家都往这个分支提交,这个分支 ...

  10. Brouwer fixed-point theorem

    w https://en.wikipedia.org/wiki/Brouwer_fixed-point_theorem https://zh.wikipedia.org/wiki/布劳威尔不动点定理 ...