servlet得到webroot路径
2016-07-02 08:54
302 查看
//file:/F:/WorkSpace/Myeclipse_Workspace_1/.metadata/.me_tcat7/webapps/Hello/WEB-INF/classes/ String classessPath = this.getClass().getResource("/").toString(); //F:/WorkSpace/Myeclipse_Workspace_1/.metadata/.me_tcat7/webapps/Hello/WEB-INF/classes/ String classessRealPath = classessPath.replace("file:/", ""); String webRootPath = classessRealPath.replace("WEB-INF/classes/", ""); File file = new File(webRootPath + "lrc"); if (!file.exists()) { file.mkdirs(); } System.out.println(file.getAbsolutePath());
相关文章推荐
- Java Servlet生成JSON格式数据并用jQuery显示的方法
- jsp和servlet中实现页面跳转的方式实例总结
- java servlet结合mysql搭建java web开发环境
- Servlet与JSP间的两种传值情况
- JSP、Servlet中get请求和post请求的区别总结
- jsp和servlet的区别探讨
- Struts2访问servlet分享
- java中Servlet处理乱码的方法
- Servlet 过滤器详细介绍
- JSP+Servlet+JavaBean实现登录网页实例详解
- servlet中session简介和使用例子
- 在Jsp Servlet中页面重新定向总汇
- JSP使用Servlet作为控制器实现MVC模式实例详解
- JSP使用Servlet过滤器进行身份验证的方法
- Servlet动态网页技术详解
- jsp和servlet操作mysql中文乱码问题的解决办法
- 基于jsp+servlet实现的简单博客系统实例(附源码)
- js调用后台servlet方法实例
- 利用JQuery和Servlet实现跨域提交请求示例分享