当前位置: 首页>>代码示例>>Java>>正文


Java PortalUtil.getHttpServletRequest方法代码示例

本文整理汇总了Java中com.liferay.portal.util.PortalUtil.getHttpServletRequest方法的典型用法代码示例。如果您正苦于以下问题:Java PortalUtil.getHttpServletRequest方法的具体用法?Java PortalUtil.getHttpServletRequest怎么用?Java PortalUtil.getHttpServletRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.liferay.portal.util.PortalUtil的用法示例。


在下文中一共展示了PortalUtil.getHttpServletRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendFile

import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
/**
 * Send file.
 *
 * @param name the name
 * @param mimeType the mime type
 * @param contents the contents
 * @param request the request
 * @param response the response
 */
protected void sendFile(final String name, final String mimeType,
        final byte[] contents, final ActionRequest request,
        final ActionResponse response) {
	try {
		if (name != null && mimeType != null && contents != null) {
			final HttpServletRequest httpServletRequest = PortalUtil
			        .getHttpServletRequest(request);
			final HttpServletResponse httpServletResponse = PortalUtil
			        .getHttpServletResponse(response);

			httpServletResponse.setContentType(mimeType);
			httpServletResponse.setHeader("Expires", "0");
			httpServletResponse.setHeader("Cache-Control",
			        "must-revalidate, post-check=0, pre-check=0");
			httpServletResponse.setHeader("Pragma", "public");
			httpServletResponse.setContentLength(contents.length);
			ServletResponseUtil.sendFile(httpServletRequest,
			        httpServletResponse, name, contents);
		}
	} catch (final Throwable t) {
		t.printStackTrace();
	}
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:33,代码来源:BaseController.java

示例2: exportAction

import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
@ProcessAction(name = "exportAction")
public void exportAction(ActionRequest request, ActionResponse response) {

	try {
		long userId = com.liferay.portal.util.PortalUtil.getUserId(request);
		long companyId = com.liferay.portal.util.PortalUtil
				.getCompanyId(request);

		List<Application> applicationsPerUser = ApplicationLocalServiceUtil
				.getDeveloperApplications(companyId, userId);

		GovAppsExport export = new GovAppsExport();

		for (Application _application : applicationsPerUser) {

			// add application
			ApplicationType xml = exportApp(_application);
			if (xml != null)
				export.getAppplications().add(xml);

		}

		JAXBContext jctx = JAXBContext
				.newInstance("de.fraunhofer.fokus.oefit.schemagen");
		Marshaller m = jctx.createMarshaller();
		StringWriter sw = new StringWriter();
		m.marshal(export, sw);

		HttpServletRequest httpServletRequest = (HttpServletRequest) PortalUtil
				.getHttpServletRequest(request);
		HttpServletResponse httpServletResponse = (HttpServletResponse) PortalUtil
				.getHttpServletResponse(response);

		httpServletResponse.setHeader("Expires", "0");
		httpServletResponse.setHeader("Cache-Control",
				"must-revalidate, post-check=0, pre-check=0");
		httpServletResponse.setHeader("Pragma", "public");
		// setting the content type
		sw.flush();
		String content = sw.toString();
		sw.close();
		httpServletResponse.setContentLength(content.length());
		com.liferay.portal.kernel.servlet.ServletResponseUtil.sendFile(
				httpServletRequest, httpServletResponse, "export.xml",
				content.getBytes("UTF-8"));

	} catch (Throwable t) {
		request.setAttribute("errorMsg", t.getMessage());
		response.setRenderParameter("jspPage", errorJSP);
	}

}
 
开发者ID:fraunhoferfokus,项目名称:govapps,代码行数:53,代码来源:ApplicationPortlet.java


注:本文中的com.liferay.portal.util.PortalUtil.getHttpServletRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。