本文整理汇总了Java中org.apache.struts2.ServletActionContext.getResponse方法的典型用法代码示例。如果您正苦于以下问题:Java ServletActionContext.getResponse方法的具体用法?Java ServletActionContext.getResponse怎么用?Java ServletActionContext.getResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.struts2.ServletActionContext
的用法示例。
在下文中一共展示了ServletActionContext.getResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getForfeitInfoById
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
public String getForfeitInfoById(){
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/json;charset=utf-8");
ForfeitInfo forfeitInfo = new ForfeitInfo();
forfeitInfo.setBorrowId(borrowId);
ForfeitInfo newForfeitInfo = forfeitService.getForfeitInfoById(forfeitInfo);
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setJsonPropertyFilter(new PropertyFilter() {
public boolean apply(Object obj, String name, Object value) {
if(obj instanceof Authorization||name.equals("authorization") || obj instanceof Set || name.equals("borrowInfos")){
return true;
}else{
return false;
}
}
});
JSONObject jsonObject = JSONObject.fromObject(newForfeitInfo,jsonConfig);
try {
response.getWriter().print(jsonObject);
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
return null;
}
示例2: getBorrowInfoById
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 根据借阅id查询该借阅信息
* @return
*/
public String getBorrowInfoById(){
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/json;charset=utf-8");
BorrowInfo info = new BorrowInfo();
info.setBorrowId(borrowId);
BorrowInfo newInfo = borrowService.getBorrowInfoById(info);
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setJsonPropertyFilter(new PropertyFilter() {
public boolean apply(Object obj, String name, Object value) {
if(obj instanceof Authorization||name.equals("authorization") || obj instanceof Set || name.equals("borrowInfos")){
return true;
}else{
return false;
}
}
});
JSONObject jsonObject = JSONObject.fromObject(newInfo,jsonConfig);
try {
response.getWriter().print(jsonObject);
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
return null;
}
示例3: getUrl
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取小说介绍页URL
*
* @return 小说介绍页URL
*/
public String getUrl() {
HttpServletResponse response = ServletActionContext.getResponse();
String url = response.encodeURL(InfoAction.URL + "?subdir=" + getSubdir() + "&articleno=" + getArticleno());
if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_PINYINURL, false)) {
url = response.encodeURL(InfoAction.URL + "?pinyin=" + getPinyin());
}
return url;
}
示例4: getLastChapterUrl
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取最新章节URL
*
* @return 最新章节URL
*/
public String getLastChapterUrl() {
HttpServletResponse response = ServletActionContext.getResponse();
String url = response.encodeURL(ReaderAction.URL + "?subdir=" + getSubdir() + "&articleno=" + getArticleno()
+ "&chapterno=" + getLastchapterno());
if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_PINYINURL, false)) {
url = response.encodeURL(ReaderAction.URL + "?pinyin=" + getPinyin() + "&chapterno=" + getLastchapterno());
}
return url;
}
示例5: getChapterListUrl
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取章节列表URL
*
* @return 分类列表URL
*/
public String getChapterListUrl() {
HttpServletResponse response = ServletActionContext.getResponse();
String url = response.encodeURL(ChapterListAction.URL + "?subdir=" + getSubdir() + "&articleno="
+ getArticleno());
if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_PINYINURL, false)) {
url = response.encodeURL(ChapterListAction.URL + "?pinyin=" + getPinyin());
}
return url;
}
示例6: getAllBookTypes
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 得到图书类型的集合
* ajax请求该方法
* 返回图书类型集合的json对象
* @return
*/
public String getAllBookTypes(){
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/json;charset=utf-8");
List<BookType> allBookTypes = bookTypeService.getAllBookTypes();
String json = JSONArray.fromObject(allBookTypes).toString();//List------->JSONArray
try {
response.getWriter().print(json);
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
return null;
}
示例7: getLastChapterUrl
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取最新章节URL
*
* @return 最新章节URL
*/
public String getLastChapterUrl() {
HttpServletResponse response = ServletActionContext.getResponse();
String url = response.encodeURL(ReaderAction.URL + "?subdir=" + getSubdir() + "&articleno=" + getArticleno()
+ "&chapterno=" + getLastchapterno());
if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_PINYINURL, false)) {
url = response.encodeURL(ReaderAction.URL + "?pinyin=" + getPinyin() + "&chapterno=" + getLastchapterno());
}
return url;
}
示例8: getUrl
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取章节列表URL
*
* @return 分类列表URL
*/
public String getUrl() {
HttpServletResponse response = ServletActionContext.getResponse();
String url = response.encodeURL(ReaderAction.URL + "?subdir=" + getSubdir() + "&articleno=" + getArticleno()
+ "&chapterno=" + getChapterno());
if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_PINYINURL, false)) {
url = response.encodeURL(ReaderAction.URL + "?pinyin=" + pinyin + "&chapterno=" + getChapterno());
}
return url;
}
示例9: getInfoUrl
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取最新章节URL
*
* @return 最新章节URL
*/
public String getInfoUrl() {
HttpServletResponse response = ServletActionContext.getResponse();
String url = response.encodeURL(InfoAction.URL + "?subdir=" + getSubdir() + "&articleno=" + getArticleno());
if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_PINYINURL, false)) {
url = response.encodeURL(InfoAction.URL + "?pinyin=" + getPinyin());
}
return url;
}
示例10: getUrl
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取章节URL
*
* @return 章节URL
*/
public String getUrl() {
HttpServletResponse response = ServletActionContext.getResponse();
String url = response.encodeURL(ReaderAction.URL + "?subdir=" + getSubdir() + "&articleno=" + getArticleno()
+ "&chapterno=" + getChapterno());
return url;
}
示例11: getTagList
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取小说tag的URL
*
* @return 小说介绍页拼音形式的URL
*/
public List<TagDTO> getTagList() {
List<String> tags = Utils.getKeyWords(getArticlename());
List<TagDTO> tagList = new ArrayList<TagDTO>();
HttpServletResponse response = ServletActionContext.getResponse();
for (String tag : tags) {
TagDTO tagdto = new TagDTO();
tagdto.setTag(tag);
tagdto.setUrl(response.encodeURL(ArticleListAction.URL + "?tag=" + tag));
tagList.add(tagdto);
}
return tagList;
}
示例12: initResponseHeader
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 分析并设置contentType与headers.
*/
private static HttpServletResponse initResponseHeader(final String contentType, final String... headers) {
//分析headers参数
String encoding = DEFAULT_ENCODING;
boolean noCache = DEFAULT_NOCACHE;
for (String header : headers) {
String headerName = StringUtils.substringBefore(header, ":");
String headerValue = StringUtils.substringAfter(header, ":");
if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) {
encoding = headerValue;
} else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) {
noCache = Boolean.parseBoolean(headerValue);
} else {
throw new IllegalArgumentException(headerName + "不是一个合法的header类型");
}
}
HttpServletResponse response = ServletActionContext.getResponse();
//设置headers参数
String fullContentType = contentType + ";charset=" + encoding;
response.setContentType(fullContentType);
if (noCache) {
ServletUtils.setDisableCacheHeader(response);
}
return response;
}
示例13: getBookType
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 得到图书类型
* ajax请求该方法
* 返回图书类型集合的json对象
* @return
*/
public String getBookType(){
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/json;charset=utf-8");
BookType bookType = new BookType();
bookType.setTypeId(id);
BookType newType = bookTypeService.getBookTypeById(bookType);
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setJsonPropertyFilter(new PropertyFilter() {
public boolean apply(Object obj, String name, Object value) {
if(obj instanceof Set||name.equals("books")){//过滤掉集合
return true;
}else{
return false;
}
}
});
JSONObject jsonObject = JSONObject.fromObject(newType,jsonConfig);
try {
response.getWriter().print(jsonObject);
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
return null;
}
示例14: getAddVoteUrl
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取推荐小说URL
*
* @return 推荐小说URL
*/
public String getAddVoteUrl() {
HttpServletResponse response = ServletActionContext.getResponse();
return response.encodeURL(VoteAction.URL + "?articleno=" + getArticleno());
}
示例15: getPreChapterThumbnailUrl
import org.apache.struts2.ServletActionContext; //导入方法依赖的package包/类
/**
* 获取下一章章节URL
*
* @return 上一章章节URL
*/
public String getPreChapterThumbnailUrl() {
HttpServletResponse response = ServletActionContext.getResponse();
return response.encodeURL(ReaderAction.URL + "?chapterno=" + getPreChapterno());
}