JS获取项目根目录】的更多相关文章

getRootPath = function(){ //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp var curWwwPath = window.document.location.href; //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp var pathName = window.document.location.pathname; var pos = curWwwPath…
function getRootPath(){ //获取当前网址,如: http://localhost:8088/test/test.jsp var curPath=window.document.location.href; //获取主机地址之后的目录,如: test/test.jsp var pathName=window.document.location.pathname; var pos=curPath.indexOf(pathName); //获取主机地址,如: http://lo…
https://www.cnblogs.com/zhouqing/archive/2012/11/10/2757774.html 序言 在开发过程中经常会用到读写文件,其中就必然涉及路径问题.使用固定的绝对路径当然很方便,但会导致程序的可移植性差,比如在代码中写死了要在E盘建一个文件,而移植后的环境中木有E盘,那就只能改代码:又或者需要调用D盘某某某很长路径下的一个自定义文件,这个文件路径又不在项目文件夹下,则拷项目代码时很容易遗漏这个自定义文件,这样给项目的交接带来了不必要的麻烦.如果我们将自…
//js获取项目根路径,如: http://localhost:8083/uimcardprj function getRootPath(){ //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp var curWwwPath=window.document.location.href; //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp var pathName=window.document.…
/** * 获得站点url * @return */ public String getWebUrl(){ String url = getRequest().getScheme() + "://" + getRequest().getServerName(); if(getRequest().getServerPort()!=80){ url+= ":" + getRequest().getServerPort(); } url+=getRequest().get…
function getRootPath(){        var strFullPath=window.document.location.href;        var strPath=window.document.location.pathname;        var pos=strFullPath.indexOf(strPath);        var prePath=strFullPath.substring(0,pos);        var postPath=strP…
代码入下: request.getSession().getServletContext().getRealPath(); 这里的getRealPath()括号里面可以输入你想得到的具体目录. 需要注意的一点是,如果仅仅是获取项目根目录,不用再括号里加任何东西.但是如果要加上子目录,则必须在前面加上"/". 代码如下: request.getSession().getServletContext().getRealPath("/resource/jsonp/newsDetai…
写在前面 图片上传功能, web项目部署在本地Tomcat上并没有问题, 但是打成war包部署到Linux服务器Weblogic下却出现如题问题, 导致图片上传失败. 问题代码 String realPath = uploadFile.getMultipartRequest().getSession().getServletContext().getRealPath("/") + "/" + path;// 文件的硬盘真实路径 在Windows下部署到Tomcat没…
//js获取网站根路径(站点及虚拟目录),获得网站的根目录或虚拟目录的根地址         function getRootPath(){        var strFullPath=window.document.location.href;        var strPath=window.document.location.pathname;        var pos=strFullPath.indexOf(strPath);        var prePath=strFull…
一 相对路径的获得 说明:相对路径(即不写明时候到底相对谁)均可通过以下方式获得(不论是一般的java项目还是web项目) String relativelyPath=System.getProperty("user.dir");  上述相对路径中,java项目中的文件是相对于项目的根目录 web项目中的文件路径视不同的web服务器不同而不同(tomcat是相对于 tomcat安装目录\bin) 二 类加载目录的获得(即当运行时某一类时获得其装载目录) 1.1)通用的方法一(不论是一般…
编写程序的时候,经常需要用的项目根目录.自己总结如下 1.取得控制台应用程序的根目录方法     方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径     方法2.AppDomain.CurrentDomain.BaseDirectory 获取基目录,它由程序集冲突解决程序用来探测程序集 2.取得Web应用程序的根目录方法     方法1.HttpRuntime.AppDomainAppPath.ToString();//获取承载在当前应用程…
这篇文章是别的博客复下来,收藏的: 编写程序的时候,经常需要用的项目根目录.自己总结如下 1.取得控制台应用程序的根目录方法     方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径     方法2.AppDomain.CurrentDomain.BaseDirectory 获取基目录,它由程序集冲突解决程序用来探测程序集 2.取得Web应用程序的根目录方法     方法1.HttpRuntime.AppDomainAppPath.ToStr…
//获取项目名称function getWebName(){ var pathName = window.location.pathname.substring(1); var webName = pathName == ''? '' : "/"+pathName.substring(0, pathName.indexOf('/')); if(webName=='/pages'||webName=='/'){ webName = ''; } return webName;}…
function getRootPath_web() { //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp var curWwwPath = window.document.location.href; //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp var pathName = window.document.location.pathname; var pos = curWwwPath…
//获取路径 var pathName=window.document.location.pathname; //截取,得到项目名称 var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);…
https://blog.csdn.net/whatlookingfor/article/details/51538995 在SpringMVC框架中使用Freemarker试图时,要获取根路径的方式如下: <!-- FreeMarker视图解析 如返回userinfo..在这里配置后缀名ftl和视图解析器.. --> <bean id="viewResolverFtl" class="org.springframework.web.servlet.view…
无法使用: Server.Map("~"); Server.Map("~/"); Server.Map("./"); Server.Map("."); 正确方式: var serverFile = System.Web.Hosting.HostingEnvironment.MapPath("~/");…
String path; public void main(String[] args) { File file=new File(""); path=file.getAbsolutePath(); syso(path); } 结果: D:\svnout\borncrm-biz…
//js获取项目根路径,如: http://localhost:8083/uimcardprj function getRootPath(){ //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp var curWwwPath=window.document.location.href; //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp var pathName=window.document.…
//js获取项目根路径,如: http://localhost:8083/uimcardprjfunction getRootPath(){ //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp var curWwwPath=window.document.location.href; //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp var pathName=window.document.l…
编写程序的时候,经常需要用的项目根目录.自己总结如下 1.取得控制台应用程序的根目录方法     方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径(eg:“C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE”.)     方法2.AppDomain.CurrentDomain.BaseDirectory 获取基目录,它由程序集冲突解决程序用来探测程序集(eg:“F:\t…
  先看一下我要实现的功能界面:   这个界面的功能在图中已有展现,课程分配(教师教授哪门课程)在之前的页面中已做好.这个页面主要实现的是授课,即给老师教授的课程分配学生.此页面实现功能的步骤已在页面中有所体现,这里不再赘述,此篇文章主要介绍:我是如何通过js从前台获取数据,然后通过ajax技术向后台一般处理程序传递JSON,后台又是如何获取传来的JSON,并对JSON数据转换,然后将转换后的数据写入数据库的! 介绍这些步骤实现前,先说说自己的辛酸:絮叨辛酸,是因为为了实现这个功能,我真的用了很…
c# 如何获取项目的根目录 编写程序的时候,经常需要用的项目根目录.自己总结如下 1.取得控制台应用程序的根目录方法     方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径     方法2.AppDomain.CurrentDomain.BaseDirectory 获取基目录,它由程序集冲突解决程序用来探测程序集 2.取得Web应用程序的根目录方法     方法1.HttpRuntime.AppDomainAppPath.ToString(…
  js 获取请求网络协议.IP.端口号.项目名称 CreationTime--2018年6月19日15点54分 Author:Marydon /** * 获取url请求前缀 * @return http://127.0.0.1/demo */ function getRequestPrefix () { // 获取网络协议 var protocol = window.location.protocol; // 获取主机名+端口号 var domainPort = window.location…
springboot获取当前项目路径的地址 System.getProperty("user.dir") 输出目录:  G:\outshine\wangsoso //获取classes目录绝对路径 String path = ClassUtils.getDefaultClassLoader().getResource("").getPath(); String path = ResourceUtils.getURL("classpath:").g…
在项目当中我们可能会遇到例如改变的项目名称之后,相对应的地址就需要改变,为了减少工作量,将地址当中的项目名这一块写成动态获取的,那么最关键一点就是我要先获取它,再进行操作: 知识点整理,话不多说,直接贴代码: 获取项目名: function URLPath(msg){ var pathName = window.document.location.pathname; var projectName = pathName.substring(0,pathName.substr(1).indexOf…
一.java获取web工程路径 1),在servlet可以用一下方法取得: request.getRealPath(“/”) 例如:filepach = request.getRealPath(“/”) ”//upload//”; 2),不从jsp,或servlet中获取,只从普通java类中获取: String path = getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); SAXReader()…
原文地址:Node JS后端项目开发与生产环境总结 Node JS常用后端框架有express.koa.sails.国产框架有个egg js,已经在cnode投入生产了,还有个think js,类似think php,在此支持一波.每个框架在开发环境与生产环境都有所不同,这里以koa为例 开发环境与生产环境的区别 建立在后台模板渲染(ejs, pug)的基础上.前后分离架构请参考webpack热更新实现 开发环境 热更新 错误处理 前端js代码自动打包 生产环境 静态缓存(static cach…
js获取cookie 之前用jQuery.cookie来获取cookie,虽然简单,但是项目上又多引用了一个插件,总觉得不太好,下面是我封装的js原生获取cookie的函数. function getCookie(cookieName) { //获取所有的cookie "psw=1234we; rememberme=true; user=Annie" var totalCookie = document.cookie; //获取参数所在的位置 var cookieStartAt = t…
常用: JS 获取浏览器窗口大小 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // 获取窗口宽度 if (window.innerWidth) winWidth = window.innerWidth; else if ((document.body) && (document.body.clientWidth)) winWidth = document.body.clientWidth; // 获取窗口高度 if (window.innerHeight)…