一个简单的实用工具类
package cn.jorcen.commons.util; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.ServletActionContext; /**
*
* Struts2 Web Util
*
* @author mjorcen
* @email mjorcen@gmail.com
* @dateTime Jun 4, 2014 4:51:14 PM
* @version 1
*/
public class Struts2WebUtil {
public static String getBasePath() {
StringBuilder sb = new StringBuilder();
HttpServletRequest req = ServletActionContext.getRequest();
sb.append(req.getScheme()).append("://");
sb.append(req.getServerName()).append(":").append(req.getServerPort());
sb.append(req.getContextPath()).append("/");
return sb.toString();
} public static HttpServletRequest getHttpServletRequest() { return ServletActionContext.getRequest();
}
}