必威体育Betway必威体育官网
当前位置:首页 > IT技术

Java web项目报错:HTTP Status 404 – Not Found Type Status Report Message /WebProject/ Description The ori

时间:2019-08-04 15:13:14来源:IT技术作者:seo实验室小编阅读:65次「手机版」
 

http status 404

在用intelijIDEA的时候,因为是第一次接触这个,对项目的发布很是迷糊。怎么弄老是404错误

http status 404 – Not Found


Type Status Report

message/****

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

无奈之下,换成Eclipse,发现问题也是存在。捣鼓了好几天,都不知道问题出在哪里。后来打算新建一个Web项目,新建一个index.jsp正确运行后再慢慢复制以前的项目文件到该正确web下面,看看问题出在哪里。后来终于发现了,使用新建的web项目下的默认web.xml文件时,项目正确运行:

web.xml自动生成的默认配置如下:

<?xml version="1.0" encoding="UTF-8"?>

<web-APP xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_ID" version="3.0">

<display-name>WebProject</display-name>

<welcome-file-list>

<welcome-file>index.html</welcome-file>

<welcome-file>index.htm</welcome-file>

<welcome-file>index.jsp</welcome-file>

<welcome-file>default.html</welcome-file>

<welcome-file>default.htm</welcome-file>

<welcome-file>default.jsp</welcome-file>

</welcome-file-list>

</web-app>

我原来的报错项目web.xml配置如下:

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<filter>

<filter-name>Spring filter</filter-name>

<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>

<init-param>

<param-name>encoding</param-name>

<param-value>UTF-8</param-value>

</init-param>

</filter>

<filter-mapping>

<filter-name>spring filter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

<servlet>

<servlet-name>ServletProxyService</servlet-name>

<servlet-class>com.proxy.ServletProxyService</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>ServletProxyService</servlet-name>

<url-pattern>/ServletProxyService</url-pattern>

</servlet-mapping>

<welcome-file-list>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

<ERROR-page>

<error-code>404</error-code>

<location>/error.html</location>

</error-page>

<context-param>

<param-name>contextconfiglocation</param-name>

<param-value>/WEB-INF/classes/applicationContext.xml</param-value>

</context-param>

<listener>

<listener-class>org.springframework.web.context.contextloaderlistener</listener-class>

</listener>

</web-app>

使用这个web.xml项目就无法运行:

web.xml换成自动生成的就可以运行了。具体原报错项目web.xml哪里错了,应该是springmvc相关配置出错吧!

就在刚刚:2018-7-29 12点18分

我把web.xml最后几段删除:

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

发现项目正确运行,所以就是这个spring的配置有问题。

https://blog.csdn.net/zuoyexingchennn/article/details/50426869#commentBox

这个链接完美解决了我的问题:

就是将注释里的代码改为这个:

<!-- 

 <listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

 </listener>

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/applicationContext.xml</param-value>

</context-param>  

-->

   <listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

 </listener>

   <context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>

   </context-param>

相关阅读

中国铁路客户服务中心---http://www.12306.cn

中国铁路客户服务中心---http://www.12306.cn

http/https与websocket的ws/wss的关系

今天在域名升级到HTTPS的时候遇到websocket的链接问题,之前在http下使用的是new WebSocket('ws://xxx');但是在切换到HTTPS后这个

HTTP中的Host字段

我们知道Http请求头信息里面会带有一个Host字段,很多人不是很清楚这个字段具体的作用或者用法,包括我被很多人问过也曾经有些迷茫,这

lol miss淘宝店(竞技外设店)网址http://missgame.taob

星店介绍: Miss,真名韩懿莹,是一名著名的英雄联盟解说,凭借着在撸友界的超高人气,Miss的淘宝店生意十分的火爆。Miss淘宝店有两个,一个

劳丽诗淘宝店铺网址 http://laolishidiaobao.taobao.c

淘宝星店介绍: 劳丽诗是谁?关注淘宝的人应该知道,她是阿里巴巴在纽约所上市的敲钟人之一,目前身份是一名淘宝店长。在踏入淘宝这个屌

分享到:

栏目导航

推荐阅读

热门阅读