系统配置常量,域名根目录方法
时间:2014-01-23 19:20:41
收藏:0
阅读:365
方法1:在servlet中通过代码获取,然后放置在session会话中.
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.getSession().setAttribute("basePath", basePath);
方法2:在系统常量类中定义 Constants.java
public static String ROOT = "http://localhost:8080/BNCAR2/";
在需要调用的地方直接用:Constants.ROOT,如:
<input type="hidden" name="basePath" id="basePath" value="<%=Constants.ROOT %>" />
推荐第二种方法更加方便~!
原文:http://www.cnblogs.com/simpledev/p/3530887.html
评论(0)