Java 为什么我会犯这个错误?HTTP状态404–;找不到
我正在尝试连接到数据库并写入一些记录,但我遇到了此错误 有人能帮我改正吗?我真的很感激我是java编程新手 这是我的jsp文件:NewFile.jspJava 为什么我会犯这个错误?HTTP状态404–;找不到,java,jsp,Java,Jsp,我正在尝试连接到数据库并写入一些记录,但我遇到了此错误 有人能帮我改正吗?我真的很感激我是java编程新手 这是我的jsp文件:NewFile.jsp <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> &
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="/Add" method="post" enctype="multipart/form-data">
Enter news ID: <br>
<input type="text" name="id"><br><br>
Enter title :<br>
<input type="text" name="title"><br><br>
Choose an image :
<input type="file" name="image" required="required">
<br><br>
<input type="submit" value="add news">
</form>
</body>
</html>
}
和web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"
version="3.1">
<display-name>12</display-name>
<welcome-file-list>
<welcome-file>NewFile.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>addServlet</servlet-name>
<servlet-class>com.example.saeid.Add</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>addServlet</servlet-name>
<url-pattern>NewFile</url-pattern>
</servlet-mapping>
12
NewFile.jsp
addServlet
com.example.saeid.Add
addServlet
新文件
404的原因之一是URL写得不正确,链接不正确。 如果在访问localhost:8080/NewFile.jsp页面或单击Add时收到404响应,则表单操作指向/Add,但您的url模式是NewFile。 将url模式更改为
/添加您在何处部署Servlet。在tomcat、jetty或jboss上?您的应用程序服务器监听哪个端口:8080?当你得到答案404时,你也应该告诉我们你做了什么。当您访问页面时,表单操作指向/Add,但您的url模式是NewFile。我想url模式应该是
Add
我正在使用eclipse和tomact,是的,我的侦听端口是8080。我更改了url模式,但再次出现相同的错误我更改了url模式,但再次出现相同的错误
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"
version="3.1">
<display-name>12</display-name>
<welcome-file-list>
<welcome-file>NewFile.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>addServlet</servlet-name>
<servlet-class>com.example.saeid.Add</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>addServlet</servlet-name>
<url-pattern>NewFile</url-pattern>
</servlet-mapping>