相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法
首先一点,WebRoot目录下的文件是都可以通过浏览器输入路径,直接读取到的
例如这样:

而WebRoot下面WEB-INF是无法浏览器输入路径直接读取的。
因为是受保护的。
如果jsp读取一个图片的话。
jsp在WebRoot/jsp下
图片在WebRoot/imag下
那么就要../imag/xx.jpg获取相对路径。
因为servlet程序是无法读取C:\xx\xx\xx这样的绝对路径的。
除非更改tomcat配置文件,但我觉得那样完全没有意义。
另外,要注意你请求的路径是否被拦截。
例如web.xml里面配置servlet-mapping为(此为spring mvc配置):
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
那么一切请求都会被拦截,在springmvc里寻找bean或注解,若找不到报404错误。也不可能直接jsp获取图片路径了。
报错
相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法的更多相关文章
- 【Java/Spring】Spring的配置问题,IDEA报错“No mapping found for HTTP request with URI […] in DispatcherServlet”
从SVN上拷贝下JavaWeb项目,Spring框架的配置文件需要修改.部署好Tomcat后,启动服务,可以进入Web项目主页,但是访问其他URL时直接跳转到404,IDEA报错“No mapping ...
- Swagger 报错 no mapping found for http request with uri [/***/swagger-ui.html] in dispatcherservlet with name '***'
swagger报错: no mapping found for http request with uri [/***/swagger-ui.html] in dispatcherservlet wi ...
- console报错:No mapping found for HTTP request with URI(xxx)
console报错:No mapping found for HTTP request with URI(xxx) 报错可能原因: 1;contorl未加载成功 2;资源访问失败(所有访问全部被Dis ...
- 阿里云oss上传图片报错,The OSS Access Key Id you provided does not exist in our records.解决方法
vue项目 1.安装OSS的Node SDK npm install ali-oss --save 2.参考官方提示https://help.aliyun.com/document_detail/11 ...
- mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法
1. 问题背景 InnoDB是新版MySQL(v5.5及以后)默认的存储引擎,之前版本的默认引擎为MyISAM,因此,低于5.5版本的mysql配置文件.my.cnf中,关于InnoD ...
- 【MySQL笔记】mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法
step1:查看 1.1 Mysql命令行里输入"show engines:"查看innoddb数据引擎状态, 1.2 show variables "%_buffer% ...
- MyEclipse报错 Building workspace has encountered a problem Errors occurred during the build 的2种解决方法
1: Building workspace has encountered a problem Errors occurred during the build 如果报错这个 那么有可能是jar包,报 ...
- Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#<Object>‘的解决方法
发现问题 运行一下以前的一个Vue+webpack的 vue仿新闻网站 小项目,报错 由于自己vue学习不深入,老是这个报错,找了好久(确切的说是整整一下午^...^)才找到原因 -v- Uncau ...
- 报错:/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.29.5/UITableView.m:7943解决方法
环境:Xcode7.1.1 详细错误: *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], ...
随机推荐
- Installshield 打包安装包心得
制作简单的安装软件 声明:下面的教程,是把读者当做完全没接触过IS的角度来制作的. 1. 启动InstallShield 12.建立一个InstallShield MSI Project,如图: 2 ...
- 转 A Week with Mozilla's Rust
转自http://relistan.com/a-week-with-mozilla-rust/ A Week with Mozilla's Rust I want another systems la ...
- firefox广告拦截插件
firefox广告拦截插件: Adblock Plus Adblock Edge Adblock Plus Pop-up Addon 如果不能更新,则需要修改HOST: 117.18.232.191 ...
- Spring 依赖注入的方式
Spring 支持3中依赖注入的方式 1.属性注入 通过setter 方法注入Bean的属性或依赖的对象. <bean id = " " class = " &q ...
- xcode archive 一直是灰色的
把配置选择为device才能选build and archive的,模拟器的肯定不能build and anchive
- iOS button文字居中
新建一个UIButton的category .h @interface UIButton (QXTitleInCenter) -(instancetype)init; @end .m @impleme ...
- c# SqlHelper Class
using System;using System.Collections;using System.Collections.Generic;using System.Data;using Syste ...
- SQL Server 判定时间是否在某个时间区间内
* FROM sys.objects WHERE name=N'uF_IsRange_Date' AND [type]='FN') DROP FUNCTION uF_IsRange_Date GO S ...
- Web服务器Nginx多方位优化策略
标签:性能 Web 架构 Nginx 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://dongsong.blog.51cto.co ...
- js截取字符串显示引号两种方法
//截取字符串多余显示引号 var cutStrForNum = function (str, num) { var len = 0; for (var i = 0; i < str.lengt ...