首先声明一个config
ServletConfig config;
初始化
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
this.config = config;
}
就可以使用了
config.getServletContext().getRealPath("yourfile");
ServletConfig config;
初始化
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
this.config = config;
}
就可以使用了
config.getServletContext().getRealPath("yourfile");
解决方案 »
- struts2 国际化的问题
- 求:弹出页面在跳转时为什么又弹出一个页面
- 求助:用js关闭窗口
- 高分求救:遍历一路径下的文件及目录,并返回页面生成一棵树。
- struts2, String execute()中这段代码不太明白.
- 紧急求助:JSP用存储过程将excel导入到sql的问题!
- 像126.com这样的网站 网页不能另存为,请问他是怎么控制的?难道就没办法了?
- 控制下拉列表高度
- 基于SSH框架的网站制作问题
- 我想为我们的聊天室写一个多路组播程序,现实吗?
- 难道高手们真的就没有更好的分页方法吗(存储过程除外)?
- 为什么con=DriverManager.getConnection("jdbc:odbc:shop","","");连接数据库会出现异常?
DriverManager.getConnection("jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/jsp_server/book.mdb");用上面的那种方法得到绝对路径!!
有时要把数据库连接封装到JavaBean 中所以想用这种方法,大家再看看......