在Struts2拦截器里,构造action的URL

@SuppressWarnings("unchecked")
	public void setToGoingURL(	HttpServletRequest request,
								HttpSession httpsession,
								ActionInvocation invoker) {
		String url = ServletActionContext.getRequest().getHeader("referer");

		if (url == null || url.equals("")) {
			url = "";
			String path = ServletActionContext.getRequest().getContextPath();
			String actionName = invoker.getProxy().getActionName();
			String nameSpace = invoker.getProxy().getNamespace();
			if (StringUtils.isNotEmpty(nameSpace)) {
				url = url + path + nameSpace;

			}
			if (StringUtils.isNotEmpty(actionName)) {
				url = url + "/" + actionName + "?";
			}

			Map<String, String[]> zzMap = ServletActionContext.getRequest().getParameterMap();
			if (zzMap != null) {
				for (String s : zzMap.keySet()) {
					String[] value = zzMap.get(s);
					for (String val : value) {
						url = url + s + "=" + val + "&";
					}

				}
			}
		}
		httpsession.setAttribute(GOING_TO_URL_KEY, url);
	}

你可能感兴趣的:(invoker)