第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

springmvc.xml 無法讀取,訪問handler報錯500

springmvc.xml 無法讀取,訪問handler報錯500

Developer_Huang 2017-11-21 14:27:13
IDE下報IO錯:找不到springmvc.xml文件,F(xiàn)ileNotFoundException: class path resource [com/springmvcstudy/config/springmvc.xml] cannot be opened because it does not exist瀏覽器下報500錯誤,HTTP Status 500 - Servlet.init() for servlet springmvc threw exceptionIOException parsing XML document from class path resource [com/springmvcstudy/config/springmvc.xml]; nested exception is java.io.FileNotFoundException: class path resource?[com/springmvcstudy/config/springmvc.xml] cannot be opened because it does not exist但是我在web.xml中配置了contextConfigLocation,好像并沒有起作用。麻煩前輩們幫忙看下。springmvc項目結(jié)構(gòu)圖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" ?????????id="WebApp_ID"?version="2.5"> <servlet><!--springmvc的前端控制器--> ????<servlet-name>springmvc</servlet-name>?<!--servlet名字--> ????<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>?<!--?servlet路徑--> ????<init-param>???????<!--?指定SpringMVC加載的配置文件(配置處理器映射器,適配器等),若沒有配置contextConfigLocation,SpringMVC的配置文件的默認路徑是/WEB-INF/springmvc-servlet.xml?--> ????????<param-name>contextConfigLocation</param-name>??<!----> ????????<param-value>classpath:com/springmvcstudy/config/springmvc.xml</param-value>??<!----> ????</init-param> </servlet> ????<servlet-mapping> ????????<servlet-name>springmvc</servlet-name>????????<!--?設(shè)置所有以action結(jié)尾的請求進入SpringMVC?--> ????????<url-pattern>*.action</url-pattern>?<!-- ????????1?/*.action ????????2?/??所有請求,都由dispatch-servlet解析,但是需要讀靜態(tài)資源設(shè)置放行。 ????????3?/*??當(dāng)轉(zhuǎn)發(fā)jsp時,仍然會有dispatchservlet解析,無法根據(jù)url找到處理器handle ????????--> ????</servlet-mapping> </web-app>springmvc.xml文件<?xml?version="1.0"?encoding="UTF-8"?> <beans?xmlns="http://www.springframework.org/schema/beans" ???????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?xmlns:p="http://www.springframework.org/schema/p" ???????xmlns:context="http://www.springframework.org/schema/context" ???????xmlns:aop="http://www.springframework.org/schema/aop" ???????xmlns:mvc="http://www.springframework.org/schema/mvc" ???????xmlns:context="http://www.springframework.org/schema/context" ???????xmlns:tx="http://www.springframework.org/schema/tx" ???????xsi:schemaLocation="http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans-4.0.xsd ????????http://www.springframework.org/schema/mvc?http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd ?????????http://www.springframework.org/schema/aop?http://www.springframework.org/schema/aop/spring-aop.xsd ????????http://www.springframework.org/schema/tx?http://www.springframework.org/schema/tx/spring-tx.xsd ????????http://www.springframework.org/schema/context?http://www.springframework.org/schema/context/spring-context-4.0.xsd"> ?????<!--配置controller掃描包--> ????<context:component-scan?base-package="com.springmvcstudy"?annotation-config="true"/> ????<!--配置處理器適配器,所有的處理器適配器都實現(xiàn)HandlerAdapter接口,--> ????<bean?class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/> ????<!--?處理器映射器?--> ????<!--?根據(jù)bean的name作為url,進行查找Handler?將action的url配置在bean的name中,需要在配置hendler時候指定beanname(就是url)?--> ????<bean?class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"?/> ????<!--配置處理器,將配置的handler在spring中進行加載--> ????<bean?name="/queryItems.action"?class="com.springmvcstudy.controller.ItemsController"/> ????<!--視圖解析器,解析jsp,默認使用jstl解析,所以classpath:下要用jstl的jar包--> ????<bean?class="org.springframework.web.servlet.view.InternalResourceViewResolver"> ????????<property?name="viewClass"?value="org.springframework.web.servlet.view.JstlView"/> ????????<property?name="prefix"?value="/WEB-INF/jsp/"/> ????????<property?name="suffix"?value=".jsp"/> ????</bean> </beans>這是controllerpackage?com.springmvcstudy.controller; import?com.springmvcstudy.pojo.items; import?org.springframework.web.servlet.ModelAndView; import?org.springframework.web.servlet.mvc.Controller; import?javax.servlet.http.HttpServletRequest; import?javax.servlet.http.HttpServletResponse; import?java.util.ArrayList; import?java.util.List; /** ?*?Created?by?huang?on?2017/11/20. ?*/ public?class?ItemsController?implements?Controller{ ????public?ModelAndView?handleRequest(HttpServletRequest?request,?HttpServletResponse?response)?throws?Exception?{ ????????//?conroller---service---impl---dao,調(diào)用service查找數(shù)據(jù)庫,此處使用靜態(tài)數(shù)據(jù)模擬 ????????List<items>??itemses=new?ArrayList<items>(); ????????//向list中添加假數(shù)據(jù) ????????items?items_1?=?new?items(); ????????items_1.setName("聯(lián)想筆記本"); ????????items_1.setPrice(6000f); ????????items_1.setDetail("ThinkPad?T430?聯(lián)想筆記本電腦!"); ????????items?items_2?=?new?items(); ????????items_2.setName("蘋果手機"); ????????items_2.setPrice(5000f); ????????items_2.setDetail("iphone6蘋果手機!"); ????????itemses.add(items_1); ????????itemses.add(items_2); ????//創(chuàng)建modelAndView準(zhǔn)備填充數(shù)據(jù)、設(shè)置視圖 ????????ModelAndView?modelAndView=new?ModelAndView(); ????????//填充數(shù)據(jù) ????????modelAndView.addObject("itemses2",itemses); ????????//?設(shè)置視圖,視圖就是渲染數(shù)據(jù)的媒介,如jsp ????????modelAndView.setViewName("/WEB-INF/jsp/items/itemsList.jsp"); ????????return?modelAndView; ????} }
查看完整描述

3 回答

?
qq_20151109_0

TA貢獻22條經(jīng)驗 獲得超11個贊

你把xml文件放在java目錄下,編譯之后你在classes里就找不到這個文件,原因就是java不是文件目錄,你編譯的時候,會自動過濾掉此文件,你把它放在resources目錄下就行

查看完整回答
1 反對 回復(fù) 2017-11-21
?
慕仰2097576

TA貢獻1條經(jīng)驗 獲得超0個贊

<param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> 我在web.xml里面配置如上,xml放在Resource里面,為什么還是報錯路徑下找不到springmvc.xml?
查看完整回答
反對 回復(fù) 2019-03-12
?
灬java

TA貢獻3條經(jīng)驗 獲得超0個贊

把springmvc.xml文件放到resource目錄下

查看完整回答
反對 回復(fù) 2017-11-21
  • 3 回答
  • 0 關(guān)注
  • 3736 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號