[英]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.