java中易犯错误以及解决方法

1.

The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from 
 required .class files

缺少servlet的使用
通过点击工程-properties->java build path->libraries tab页中选择Add external Jars…按钮,知道路径直接添加,否则可以借助servlet.api在文件中查找,添加即可。
2.
-javax.servlet.jsp.JspException cannot be resolved to a type

原文链接:https://blog.csdn.net/fengspg/article/details/41645159
可能是eclipse版本问题
右键你的项目–properties选择Targeted Runtimes,选择你的运行环境,我选择Apache Tomcat v7.0,Apply即可
3.

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build path

右击项目->build path->configure build path->add external jars,在文件夹中查找servlet.api。
4.

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

右击项目->build path->configure build path->add external jars,在文件夹中查找jsp.api。
5.

Several ports (8005, 8080, 8009) required by Tomcat v9.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).

原因是由于外面通过starup.bat打开了tomcat,而在eclipse中运行时会再一次通过server打开Tomcat,造成了端口被占用。

找到Tomcat的文件夹下bin文件夹然后双击shutdown.bat关闭Tomcat后再在eclipse中运行即可。
6.

你可能感兴趣的:(java)