Java web项目获取HTTP状态500–内部服务器错误,无法解析导入com.sun.Java.swing.plaf.



我无法运行我的java web项目。我从网络上得到HTTP Status 500 – Internal Server Error,从eclipse 得到The import com.sun.java.swing.plaf.windows.resources cannot be resolved

在我从GitHub下载了一个web项目并进行了一些配置后,该项目就可以成功运行了。但一旦我尝试将网络连接到MySQL,这就是登录的功能。网络出了问题。我得到了这个

Type Exception Report
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
java.lang.NullPointerException
com.ascent.dao.LoginDAO.login(LoginDAO.java:40)
com.ascent.servlet.LoginServlet.userLogin(LoginServlet.java:183)
com.ascent.servlet.LoginServlet.doGet(LoginServlet.java:39)
com.ascent.servlet.LoginServlet.doPost(LoginServlet.java:31)
javax.servlet.http.HttpServlet.service(HttpServlet.java:682)
javax.servlet.http.HttpServlet.service(HttpServlet.java:765)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
com.ascent.util.ChangeCharsetFilter.doFilter(ChangeCharsetFilter.java:22)
Note The full stack trace of the root cause is available in the server logs.

eclipse有一个错误`The import com.sun.java.swing.plaf.windows.resources cannot be resolved`和大量的警告,例如'pst' is not closed at this location LoginDAO.java`。这个项目的代码似乎是正确的,因为我的朋友可以成功登录。

'pst' is not closed at this location LoginDAO.java表示您有未关闭的资源,例如数据库连接等。您应该在使用后关闭它,代码如下:

Connection con = DriverManager.getConnection(url:"url", user:"root", password:"password");
con.close();

更常见的是维护数据库的连接池,例如hikariCP

The import com.sun.java.swing.plaf.windows.resources cannot be resolved我认为您的代码导入重复包,您可以再次检查您的代码。希望答案对你有帮助!

最新更新