Java Code Examples for org.springframework.web.util.UrlPathHelper#getOriginatingRequestUri()

The following examples show how to use org.springframework.web.util.UrlPathHelper#getOriginatingRequestUri() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdminContextInterceptor.java    From Lottery with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 获得第三个路径分隔符的位置
 * 
 * @param request
 * @throws IllegalStateException
 *             访问路径错误,没有三(四)个'/'
 */
private static String getURI(HttpServletRequest request)
		throws IllegalStateException {
	UrlPathHelper helper = new UrlPathHelper();
	String uri = helper.getOriginatingRequestUri(request);
	String ctxPath = helper.getOriginatingContextPath(request);
	int start = 0, i = 0, count = 2;
	if (!StringUtils.isBlank(ctxPath)) {
		count++;
	}
	while (i < count && start != -1) {
		start = uri.indexOf('/', start + 1);
		i++;
	}
	if (start <= 0) {
		throw new IllegalStateException(
				"admin access path not like '/jeeadmin/jspgou/...' pattern: "
						+ uri);
	}
	return uri.substring(start);
}
 
Example 2
Source File: CmsLogMngImpl.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
public CmsLog loginSuccess(HttpServletRequest request, CmsUser user,
		String title) {
	String ip = RequestUtils.getIpAddr(request);
	UrlPathHelper helper = new UrlPathHelper();
	String uri = helper.getOriginatingRequestUri(request);
	Date date = new Date();
	CmsLog log = save(CmsLog.LOGIN_SUCCESS, null, user, uri, ip, date,
			MessageResolver.getMessage(request, title), null);
	return log;
}
 
Example 3
Source File: CmsLogMngImpl.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
public CmsLog loginFailure(HttpServletRequest request, String title,
		String content) {
	String ip = RequestUtils.getIpAddr(request);
	UrlPathHelper helper = new UrlPathHelper();
	String uri = helper.getOriginatingRequestUri(request);
	Date date = new Date();
	CmsLog log = save(CmsLog.LOGIN_FAILURE, null, null, uri, ip, date,
			MessageResolver.getMessage(request, title), content);
	return log;
}
 
Example 4
Source File: CmsLogMngImpl.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
public CmsLog operating(HttpServletRequest request, String title,
		String content) {
	CmsSite site = CmsUtils.getSite(request);
	CmsUser user = CmsUtils.getUser(request);
	String ip = RequestUtils.getIpAddr(request);
	UrlPathHelper helper = new UrlPathHelper();
	String uri = helper.getOriginatingRequestUri(request);
	Date date = new Date();
	CmsLog log = save(CmsLog.OPERATING, site, user, uri, ip, date,
			MessageResolver.getMessage(request, title), content);
	return log;
}
 
Example 5
Source File: RequestUtils.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 获得当的访问路径
 * 
 * HttpServletRequest.getRequestURL+"?"+HttpServletRequest.getQueryString
 * 
 * @param request
 * @return
 */
public static String getLocation(HttpServletRequest request) {
	UrlPathHelper helper = new UrlPathHelper();
	StringBuffer buff = request.getRequestURL();
	String uri = request.getRequestURI();
	String origUri = helper.getOriginatingRequestUri(request);
	buff.replace(buff.length() - uri.length(), buff.length(), origUri);
	String queryString = helper.getOriginatingQueryString(request);
	if (queryString != null) {
		buff.append("?").append(queryString);
	}
	return buff.toString();
}
 
Example 6
Source File: URLHelper.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
private static String getURI(HttpServletRequest request) {
	UrlPathHelper helper = new UrlPathHelper();
	String uri = helper.getOriginatingRequestUri(request);
	String ctx = helper.getOriginatingContextPath(request);
	if (!StringUtils.isBlank(ctx)) {
		return uri.substring(ctx.length());
	} else {
		return uri;
	}
}
 
Example 7
Source File: URLHelper.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 获得翻页信息
 * 
 * @param request
 * @return
 */
public static PageInfo getPageInfo(HttpServletRequest request) {
	UrlPathHelper helper = new UrlPathHelper();
	String uri = helper.getOriginatingRequestUri(request);
	String queryString = helper.getOriginatingQueryString(request);
	return getPageInfo(uri, queryString);
}