jsp中获得当前应用的相对路径和绝对路径 根目录所对应的绝对路径:request.getRequestURI() 文件的绝对路径 :application.getRealPath(request.getRequestURI()); 当前web应用的绝对路径 :application.getRealPath("/"); 取得请求文件的上层目录:new File(application.getRealPath(request.getRequestURI())).getParent() Servlet中获得当前应用的相对路径和绝对路径 根目录所对应的绝对路径:request.getServletPath(); 文件...
by qdl2010 - Java文档中心 - 2008-04-23 15:48:58 阅读(934) 回复(0)
OS 是 Solaris web 服务器是 iPlanet 请问 jsp 中怎么得到web 的根目录在系统中的绝对路径? 比如得到 "/usr/opt/SUNWapp/roothome/" 这个字符串 谢谢
System.out.println("根目录所对应的绝对路径:" + request.getServletPath() + ""); String strPathFile = request.getSession().getServletContext().getRealPath(request.getRequestURI()); System.out.println("文件的绝对路径:" + strPathFile + ""); String strDirPath = new File(request.getSession().getServletContext().getRealPath(request.getRequestURI())).getParent(); System.out.println("目录的绝对路径...
Date now = new Date(); out.println(DateFormat.getTimeInstance().format(now)); jsp to display the current time The current time is: 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/7965/showart_55812.html
%@ page contentType="text/html; charset=gb2312" language="java" import="java.io.*" errorPage="" %> html> head> meta http-equiv="Content-Type" content="text/html; charset=gb2312"> title>Untitled Document/title> /head> body> 当前web应用的物理路径:%=application.getRealPath("/")%>BR> 当前你求请的jsp文件的物理路径: %=application.getRealPat...
对于tomcat的容器,尝试这个容器的编码改一下 在server.xml的 中加入 URIEncoding="UTF-8" 修改后是这样 (上述出自: http://zhidao.baidu.com/question/48824138.html ) 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/65478/showart_1078631.html
1. % java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); java.util.Date currentTime = new java.util.Date();//得到当前系统时间 String str_date1 = formatter.format(currentTime); //将日期时间格式化 String str_date2 = currentTime.toString(); //将Date型日期时间转换成字符串形式 %> 2. SCRIPT LANGUAGE="javascript"> var myDate = new Date(); myDate.getY...
我在jsp程序中做了一个bean供页面调用, 在这个bean中我用 java.io.File 读取外部文件, 此外部文件用相对路径如何给出, 放到什么地方合适? 我用绝对路径,正常, 用相对路径提示系统找不到这个外部文件! 哪位指点一下, 谢谢!!
本帖最后由 lzj019 于 2010-03-11 21:59 编辑 问题描述: 希望将http://www.domain.com/path1/path2/ 访问服务器上一个目录 /service/storage/ ( documentRoot暂时指定到/service/storage/下) 请问在apache、nginx中如何配置 如果无法直接在配置文件中配置,那请问下Rewrite如何写
我先描述下我的意思,请知道解决方法的达人帮忙说下,先谢谢了 我现在有个接口程序,其中一个类需要读取xml配置文件,这个xml文件就存放在该类的同级目录,采用getRealPath()方法很容易找到,但是现在想把这个接口打成jar包,这样做就不好修改xml文件了(因为xml配置文件也被打包进jar里面了),所以想在调用该接口的web程序下放置这个xml文件,让这个jar包中需要读取xml文件的类还能找到该配置文件,但是小弟不清楚该怎么实现,请各...