1. 程式人生 > >Java web專案報錯:HTTP Status 404 – Not Found Type Status Report Message /WebProject/ Description The ori

Java web專案報錯:HTTP Status 404 – Not Found Type Status Report Message /WebProject/ Description The ori

在用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的配置有問題。

這個連結完美解決了我的問題:

就是將註釋裡的程式碼改為這個:

 <!-- 
   <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>

相關推薦

Java web專案HTTP Status 404Not Found Type Status Report Message /WebProject/ Description The ori

在用intelijIDEA的時候,因為是第一次接觸這個,對專案的釋出很是迷糊。怎麼弄老是404錯誤: HTTP Status 404 – Not Found Type Status Report Message/**** Description The origin

瀏覽器訪問IIS伺服器上面的plist檔案HTTP Error 404.3

報錯:HTTP Error 404.3 - Not FoundThe page you are requesting cannot be served because of the extension configuration. If the page is a scrip

Mac下安裝第三方模塊‘sqlfront.h‘ file not found的解決辦法

for found ins 解決辦法 第三方模塊 mssql erro ref div 1.軟件環境:     mac環境:10.11.6(15G31)     python: 3.6 2.問題:     sudo pip install pymssql 後出現下面問題:

alias設置別名使用的時候-bash: this: command not found

alias 報錯 centos alias用來設置指令的別名,我們可以簡化一下較長的命令。說明: 使用alias指定別名的時候一定要使用‘’將原來的命令引起來,防止特殊字符發生錯誤。 alias命令的作用只局限於該次登錄時使用,如果想長久使用就給他寫道/etc/pr

Springboot中mybatisInvalid bound statement (not found)

小場面不要驚慌,分5種情況,檢查你的配置和程式碼,看有沒有中招; xml檔案的select標籤的id對應dao檔案的方法名,兩者必須完全一致 xml檔案中的 namespace=“xxx.xxx.xxx.Mapper” 中的路徑是否與介面檔案路徑一致 xml檔案中的p

【linux】CentOS 7 使用ifconfig命令-bash: ifconfig: command not found;ip/ifcongif命令檢視網路資訊的使用

目錄 一、ip命令檢視網路資訊 二、CentOS 7啟用ifconfig命令 三、ifconfig命令檢視網路資訊 一、ip命令檢視網路資訊 (1)輸入命令檢視網絡卡資訊,找到網絡卡名稱,可以看到該網絡卡已經分配到IP地址,輸入命令: ip addr &nbs

解決pycharm 無法載入pip安裝包python packing tools not found. install packing tools

Linux下開啟 /opt/pycharm-xxxxx/helpers/packaging_tool.py windows下開啟 C:\Program Files\JetBrains\PyCharm

SSMInvalid bound statement (not found): com.app.dataMapper.ConnectMapper.getLifeTime] with root c

上一篇部落格說道執行專案的時候報了“Request processing failed; nested exception is java.lang.NullPointerException] with root cause”錯誤,這個錯誤剛修復好,結果又出現了一個問題。 附上上篇錯誤

Linux 命令列-bash:XXX: command not found ,解決方法參考

相關錯誤 我的錯誤 在CentOS中安裝jdk時, 修改配置檔案,輸入命令 : vim /etc/profile 修改完後重新編譯,輸入命令 : source /etc/profile 我的CentOS錯誤資訊是:-bash:UNset: command no

模擬器運行ld: symbol(s) not found for architecture x86_64

ont symbols efault contex 問題 lin with for lib 模擬器運行報錯: 報錯信息如下: Undefined symbols for architecture x86_64: "_x264_encoder_open_142", re

eclipse 移植cocos2d-x工程 Program "bash" is not found in PATH

前提:如果是用cygwin+NDK+eclipse環境生成的工程,工程已經添加了native super。 1、把cygwin/bin加入系統環境變數Path下 2、右擊工程-->properties-->C/C++ Build  確認右邊檢視選項Build command:ndk-build

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path Maven專案Failed to execute goal org.apache.maven.plugi

 ① The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 完整錯誤資訊: THIS SOFTWARE IS PROVIDED BY THE

項目中訪問controllerHTTP Status 500 - Servlet.init() for servlet spring threw exception

apr ssl .get beans index p s 配置 cnblogs lis 直接訪問controller路徑http://localhost:8080/index報錯: HTTP Status 500 - Servlet.init() for servlet

Eclipse中maven專案org.springframework.web.filter.CharacterEncodingFilter

寫了一個demo,發現在tomcat中部署完專案,啟動時報錯。 1,問題描述 2,解決辦法 1)程式在部署完成後報錯,說明是程式是編譯通過的,即編譯編譯路徑Java Build Path沒問題。 2)此時檢視 專案Properties—Deployment

http://localhost/ 或 http://127.0.0.1/ HTTP 404 的解決辦法

bottom modify pat tro n) 報錯 bsp 設置 cal 一些初次接觸使用 Eclipse 工具來開發 JAVA Web 工程的開發人員,可能會對 Eclipse 和 Tomcat 的綁定產生一個疑惑。 那就是 在修改了 Tom

pyspider HTTP 599: SSL certificate problem: self signed certificate in certificate chain解決方案

出現上述問題,可以在抓取函式的crawl 方法中加入忽略證書驗證,validate_cert=False 即:self.crawl('__START_URL__', callback=self.index_page, validate_cert=False) validate_cert

Ionic新建專案OpenSSH not found on your computer.

錯誤資訊: D:\project\eyeshot\eyeshot>ionic ssh setup [WARN] OpenSSH not found on your computer. [ERROR] Command not found: ssh 解決辦法: 下載安裝SSH:http

IDEA啟動web專案

1.問題: MLog initialization issue: slf4j found no binding or threatened to use its (dangerously silent) NOPL 報錯介面: 解決參考: SLF4J:無法載入類“org.slf4

maven建web專案

網上比較流行的解決方法有兩種: 1.在Eclipse Maven配置中新增新的Catalog配置 2.在本地庫中裝載maven-archetype-quickstart 我先試了試第一個方法,配置後沒有任何效果。再用第二個方法,配置完後試著建立maven-archetype-

java 控制檯老是Operation not allowed after ResultSet closed

百度了很多,都是說一個st對應一個rs,真是複雜! 怎麼改都報錯!! 總結一下自己的錯誤: 最常見的的是查詢操作,因為利用到rs結果集 while(rs.next){ list.add(rs.getString(1)) } 的時候, 勸各位不要放在工具包jdbc