本文整理汇总了Java中com.liferay.portal.kernel.servlet.ServletResponseUtil.write方法的典型用法代码示例。如果您正苦于以下问题:Java ServletResponseUtil.write方法的具体用法?Java ServletResponseUtil.write怎么用?Java ServletResponseUtil.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.kernel.servlet.ServletResponseUtil
的用法示例。
在下文中一共展示了ServletResponseUtil.write方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doServeResource
import com.liferay.portal.kernel.servlet.ServletResponseUtil; //导入方法依赖的package包/类
@Override
protected void doServeResource(ResourceRequest request, ResourceResponse response)
throws Exception {
String cmd = ParamUtil.getString(request, Constants.CMD);
String serializedJson = "";
if(cmd.equals(CMD_PAGELIST)) {
serializedJson = getPageLists(request,response );
} else {
_log.error("Unknown command is passed <" + cmd + ">");
}
HttpServletResponse servletResponse = _portal.getHttpServletResponse(
response);
servletResponse.setContentType(ContentTypes.APPLICATION_JSON);
ServletResponseUtil.write(servletResponse, serializedJson);
}
示例2: doServeResource
import com.liferay.portal.kernel.servlet.ServletResponseUtil; //导入方法依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
String serializedJson = "";
if (cmd.equals(CMD_ROLELIST)) {
serializedJson = getRoleLists(resourceRequest, resourceResponse);
} else {
_log.error("Unknown command is passed <" + cmd + ">");
}
HttpServletResponse response = _portal.getHttpServletResponse(resourceResponse);
response.setContentType(ContentTypes.APPLICATION_JSON);
ServletResponseUtil.write(response, serializedJson);
}
示例3: doServeResource
import com.liferay.portal.kernel.servlet.ServletResponseUtil; //导入方法依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws Exception {
String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
String serializedJson = "";
if(cmd.equals(CMD_THREAD_LIST)) {
serializedJson = getThreadList(resourceRequest,resourceResponse );
} else if (cmd.equals(CMD_CATEGORY_LIST)) {
serializedJson = getCategoryList(resourceRequest,resourceResponse );
} else {
_log.error("Unknown command is passed <" + cmd + ">");
}
HttpServletResponse response = _portal.getHttpServletResponse(
resourceResponse);
response.setContentType(ContentTypes.APPLICATION_JSON);
ServletResponseUtil.write(response, serializedJson);
}
示例4: _writeSampleHTML
import com.liferay.portal.kernel.servlet.ServletResponseUtil; //导入方法依赖的package包/类
/**
* Write sample HTML
*
* @param resp
*/
private void _writeSampleHTML(HttpServletResponse resp) {
resp.setCharacterEncoding(StringPool.UTF8);
resp.setContentType(ContentTypes.TEXT_HTML_UTF8);
resp.setStatus(HttpServletResponse.SC_OK);
try {
ServletResponseUtil.write(resp, _generateSampleHTML());
}
catch (Exception e) {
if (_log.isWarnEnabled()) {
_log.warn(e, e);
}
resp.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
}
}
示例5: doServeResource
import com.liferay.portal.kernel.servlet.ServletResponseUtil; //导入方法依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws Exception {
int numberOfCrawlers = ParamUtil.getInteger(resourceRequest, "numberOfCrawlers", -1);
int maxDepthOfCrawling = ParamUtil.getInteger(resourceRequest, "maxDepthOfCrawling", -1);
int maxPagesToFetch = ParamUtil.getInteger(resourceRequest, "maxPagesToFetch", -1);
String tmpUrls = ParamUtil.getString(resourceRequest, "urls", "https://www.shutterstock.com/photos");
String[] strArray = tmpUrls.split(",");
List<String> urls = new ArrayList<>(Arrays.asList(strArray));
List<String> result = Lists.newArrayList();
if(_log.isDebugEnabled()) {
_log.debug("numberOfCrawlers : " + String.valueOf(numberOfCrawlers));
_log.debug("maxDepthOfCrawling : " + String.valueOf(maxDepthOfCrawling));
_log.debug("maxPagesToFetch : " + String.valueOf(maxPagesToFetch));
}
if( numberOfCrawlers >= 0 &&
maxDepthOfCrawling >= 0 &&
maxPagesToFetch >= 0 ) {
// Run image links crawler
result = run(numberOfCrawlers, maxDepthOfCrawling, maxPagesToFetch, urls);
}
HttpServletResponse response = _portal.getHttpServletResponse(resourceResponse);
response.setContentType(ContentTypes.APPLICATION_JSON);
String serializedJson = createReturnJson(resourceRequest, resourceResponse, result);
ServletResponseUtil.write(response, serializedJson);
}
示例6: writeJSON
import com.liferay.portal.kernel.servlet.ServletResponseUtil; //导入方法依赖的package包/类
protected void writeJSON(
PortletRequest portletRequest, ActionResponse actionResponse,
Object json)
throws IOException {
HttpServletResponse response =
PortalUtil.getHttpServletResponse(actionResponse);
response.setContentType(ContentTypes.APPLICATION_JSON);
ServletResponseUtil.write(response, json.toString());
response.flushBuffer();
setForward(portletRequest, COMMON_NULL);
}
示例7: doServeResource
import com.liferay.portal.kernel.servlet.ServletResponseUtil; //导入方法依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws Exception {
String serializedJson = "";
serializedJson = getCategoryList(resourceRequest, resourceResponse);
HttpServletResponse response = _portal.getHttpServletResponse(resourceResponse);
response.setContentType(ContentTypes.APPLICATION_JSON);
ServletResponseUtil.write(response, serializedJson);
}