[英]Why can not reach my web application?
我正在嘗試使用Maven創建一個簡單的Web應用程序,該應用程序僅連接到mssql服務器,而我的IDE是IntelliJ。 這是我的index.jsp文件:
<%@ page import="java.io.IOException" %>
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection connection =
DriverManager.getConnection("jdbc:sqlServer://127.0.0.1;
databaseName=database password=passwordd");
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select * from tablo
where id = 10");
while(resultSet.next()){
out.println(resultSet.getArray(0) + " " + resultSet.getArray(1));
}
}catch(IOException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}catch(ClassNotFoundException e){
e.printStackTrace();
}
%>
</body>
</html>
我沒有更改web.xml文件,因此它只是空的。 我的問題是,當我在tomcat服務器上運行Web應用程序時,出現HTTP Status 404-Not Found錯誤。 URL是"http://localhost:8080/"
。 而且我也嘗試了http://localhost:8080/index.jsp
和"http://localhost:8080/webapp/index.jsp"
但結果是相同的。 感覺我沒有提供足夠的信息,這僅僅是因為我是創建Web應用程序的新手。 我在哪里做錯了?
編輯:
我只是改變了部署Web項目和工作方式的方式。 那是mywebapp: war
,現在是mywebapp: war exploded
。 為什么現在有效? 它們或指向我的項目文件夾有什么區別? -
我的問題與我部署Web項目的方式有關。 當我將其部署為MyWebApp: war exploded
它運行得非常完美。 希望它會幫助某人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.