tomcat生成文件位置问题 本帖最后由 linjky 于 2009-07-02 17:02:32 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 application.getRealPath("/"); 这个就是你的项目的根目录。tomcat默认的当前目录是 tomcat/bin 可不可以用, Servlet.getSerletContextPath() 可能不太对, application.getRealPath("/"); 我试了,是获得我项目的绝对地址Servlet.getSerletContextPath();是获得的什么呀,还有Servlet怎么在struts2里怎么获取。 request.getContextPath()struts2 Action中获取request, response对象的方法 ActionContext ctx = ActionContext.getContext(); HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE); http://lxy19791111.javaeye.com/blog/135771 servlet里经常会用到一些GET方法,容易弄混,把它们记在这儿了。servletContext.getContextPath()=servletContext.getRealPath("/")=F:\ess-branch\web\servletContext.getRealPath("")=F:\ess-branch\webservletContext.getContextPath()=servletContext.getServerInfo()=Apache Tomcat/6.0.18http://hi.baidu.com/atomicface/blog/item/de62ac10c099c8cea6ef3f5b.html 用servletContext.getRealPath(path)或request.getServletContext().getRealPath(path);不要用request.getRealPath(path),这个方法在api中是不推荐的,部分服务器不支持此方法(如某些版本的weblogic) 跪求jbpm4.X的 web 流程设计器 要中文版的 请解答我心中对Hibernate无尽纠结吧 ejb和javabean什么区别 做论坛遇到的表设计问题 ACEGI的过滤问题 请不要将与技术无关的问题发布到论坛中,让我们这仅有的技术交流地带成为程序员的乐土! 如何在servicemix中用webservice? 大家讨论一下关于JSTL标签在项目中的使用问题! 关于JTapi 请各位帮忙 RTX Java二次开发 事件调用 一个关于网络拓扑的问题 tomcat下怎么发布jsp
Servlet.getSerletContextPath();是获得的什么呀,还有Servlet怎么在struts2里怎么获取。
HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE); http://lxy19791111.javaeye.com/blog/135771
servletContext.getRealPath("/")=F:\ess-branch\web\
servletContext.getRealPath("")=F:\ess-branch\web
servletContext.getContextPath()=
servletContext.getServerInfo()=Apache Tomcat/6.0.18
http://hi.baidu.com/atomicface/blog/item/de62ac10c099c8cea6ef3f5b.html
不要用request.getRealPath(path),这个方法在api中是不推荐的,部分服务器不支持此方法(如某些版本的weblogic)