快捷导航

springmvc.xml 无法读取,访问handler报错500

IDE下报IO错:找不到springmvc.xml文件,FileNotFoundException: 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项目结构图web.xml文件springmvcorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:com/springmvcstudy/config/springmvc.xmlspringmvc*.actionspringmvc.xml文件这是controllerpackagecom.springmvcstudy.controller;importcom.springmvcstudy.pojo.items;importorg.springframework.web.servlet.ModelAndView;importorg.springframework.web.servlet.mvc.Controller;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importjava.util.ArrayList;importjava.util.List;/***Createdbyhuangon2017/11/20.*/publicclassItemsControllerimplementsController{publicModelAndViewhandleRequest(HttpServletRequestrequest,HttpServletResponseresponse)throwsException{//conroller---service---impl---dao,调用service查找数据库,此处使用静态数据模拟Listitemses=newArrayList();//向list中添加假数据itemsitems_1=newitems();items_1.setName("联想笔记本");items_1.setPrice(6000f);items_1.setDetail("ThinkPadT430联想笔记本电脑!");itemsitems_2=newitems();items_2.setName("苹果手机");items_2.setPrice(5000f);items_2.setDetail("iphone6苹果手机!");itemses.add(items_1);itemses.add(items_2);//创建modelAndView准备填充数据、设置视图ModelAndViewmodelAndView=newModelAndView();//填充数据modelAndView.addObject("itemses2",itemses);//设置视图,视图就是渲染数据的媒介,如jspmodelAndView.setViewName("/WEB-INF/jsp/items/itemsList.jsp");returnmodelAndView;}}

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员3

你把xml文件放在java目录下,编译之后你在classes里就找不到这个文件,原因就是java不是文件目录,你编译的时候,会自动过滤掉此文件,你把它放在resources目录下就行
回复

使用道具 举报

contextConfigLocation  classpath:springmvc.xml 我在web.xml里面配置如上,xml放在Resource里面,为什么还是报错路径下找不到springmvc.xml?
回复

使用道具 举报

把springmvc.xml文件放到resource目录下
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP