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


Java ServletActionContext类代码示例

本文整理汇总了Java中org.apache.struts2.ServletActionContext的典型用法代码示例。如果您正苦于以下问题:Java ServletActionContext类的具体用法?Java ServletActionContext怎么用?Java ServletActionContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getHistory

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
/**
 * <p>
 * 取得阅读历史
 * </p>
 */
private void getHistory() {
    logger.debug("getHistory start.");
    // 获得阅读履历
    String historys = CookieUtils.getHistoryCookie(ServletActionContext.getRequest());
    if (StringUtils.isNotEmpty(historys)) {
        String[] acnos = StringUtils.split(historys, ",");
        List<String> articlenoList = new ArrayList<String>();
        for (String articleAndchapterno : acnos) {
            String[] acnoArr = StringUtils.split(articleAndchapterno, "|");
            if (acnoArr.length > 0) {
                articlenoList.add(acnoArr[0]);
            }
        }
        if (articlenoList.size() > 0) {
            ArticleSearchBean searchBean = new ArticleSearchBean();
            searchBean.setArticlenos(StringUtils.join(articlenoList, ","));
            dto.setItems(articleService.find(searchBean));
        }
        dto.setCode(ReturnCode.SUCCESS);
    }
    logger.debug("getHistory normally end.");
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:28,代码来源:AjaxServiceAction.java

示例2: findMyForfeitInfoByPage

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
public String findMyForfeitInfoByPage(){
	Reader reader = (Reader) ServletActionContext.getContext().getSession().get("reader");
	//获取页面传递过来的当前页码数
	if(pageCode==0){
		pageCode = 1;
	}
	//给pageSize,每页的记录数赋值
	int pageSize = 5;
	PageBean<ForfeitInfo> pb = null;
	pb = forfeitService.findMyForfeitInfoByPage(reader,pageCode,pageSize);
	if(pb!=null){
		pb.setUrl("findMyForfeitInfoByPage.action?");
	}
	ServletActionContext.getRequest().setAttribute("pb", pb);
	return "success";
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:17,代码来源:ForfeitAction.java

示例3: readerInfo

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
/**
 * 读者个人资料
 * @return
 */
public String readerInfo(){
	Map<String, Object> session = ServletActionContext.getContext().getSession();
	Reader reader = (Reader) session.get("reader");
	reader.setName(name);
	reader.setPhone(phone);
	reader.setEmail(email);
	Reader newReader = readerService.updateReaderInfo(reader);
	int success = 0;
	if(newReader!=null){
		success = 1;
		//重新存入session
		session.put("reader", newReader);
	}
	try {
		ServletActionContext.getResponse().getWriter().print(success);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		throw new RuntimeException(e.getMessage());
	}
	return null;
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:26,代码来源:ReaderInfoAction.java

示例4: deleteBookType

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
/**
 * 删除图书类型
 * @return
 */
public String deleteBookType(){
	BookType bookType = new BookType();
	bookType.setTypeId(id);
	boolean deleteType = bookTypeService.deleteBookType(bookType);
	int success = 0;
	if(deleteType){
		success = 1;
		//由于是转发并且js页面刷新,所以无需重查
	}
	try {
		ServletActionContext.getResponse().getWriter().print(success);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		throw new RuntimeException(e.getMessage());
	}
	
	return null;
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:23,代码来源:BookTypeManageAction.java

示例5: 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;
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:17,代码来源:BookcaseDTO.java

示例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;
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:22,代码来源:BookAction.java

示例7: setReferer

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
/**
 * 设置Referer
 * 
 */
public static void setReferer() {
    String refererPath = (String) ServletActionContext.getRequest().getHeader(REFERER_KEY);
    // 如果URL里没有本站域名的话,设置本站域名为默认值
    if (!(StringUtils.contains(refererPath, YiDuConstants.yiduConf.getString(YiDuConfig.URI)) && StringUtils
            .contains(refererPath, YiDuConstants.yiduConf.getString(YiDuConfig.URI)))) {
        refererPath = YiDuConstants.yiduConf.getString(YiDuConfig.URI);
    }
    HttpSession session = getSession(true);
    logger.debug("REFERER_KEY : " + refererPath);
    session.setAttribute(REFERER_KEY, refererPath);
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:16,代码来源:LoginManager.java

示例8: dologin

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
/**
 * <p>
 * 用户登录
 * </p>
 */
private void dologin() {
    logger.info("dologin start.");
    TUser user = userService.findByLoginInfo(loginid, Utils.convert2MD5(password));
    if (user != null && user.getDeleteflag() != null && !user.getDeleteflag()) {
        // 正常登录
        LoginManager.doLogin(user);
        // 更新用户最后登录时间
        user.setLastlogin(new Date());
        userService.save(user);
        Cookie cookie = CookieUtils.addUserCookie(user);
        // 添加cookie到response中
        ServletActionContext.getResponse().addCookie(cookie);
        dto.setCode(ReturnCode.SUCCESS);
        logger.debug("dologin normally end.");
    } else {
        dto.setCode(ReturnCode.FAILED);
        dto.setErr(getText("errors.login.failed"));
        logger.debug("dologin abnormally end.");
    }

}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:27,代码来源:AjaxServiceAction.java

示例9: readerPwd

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
/**
 * 读者密码修改
 * @return
 */
public String readerPwd(){
	Reader reader = (Reader) ServletActionContext.getContext().getSession().get("reader");
	int state = -1;//原密码错误
	//取出原密码进行比对
	if(reader.getPwd().equals(Md5Utils.md5(oldPwd))){
		if(newPwd.equals(confirmPwd)){
			state = 1;//修改成功
			reader.setPwd(Md5Utils.md5(newPwd));
			reader = readerService.updateReaderInfo(reader);
			//重新存入session
			ServletActionContext.getContext().getSession().put("reader", reader);
		}else{
			state = 0;//确认密码不一致
		}
	}
	try {
		ServletActionContext.getResponse().getWriter().print(state);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		throw new RuntimeException(e.getMessage());
	}
	return null;
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:28,代码来源:ReaderInfoAction.java

示例10: getBook

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
/**
 * 得到指定图书编号的图书信息
 * ajax请求该方法
 * 返回该图书信息的json对象
 * @return
 */
public String getBook(){
	HttpServletResponse response = ServletActionContext.getResponse();
	response.setContentType("application/json;charset=utf-8");
	Book book = new Book();
	book.setBookId(bookId);
	Book newBook = bookService.getBookById(book);//得到图书
	
	JsonConfig jsonConfig = new JsonConfig();
	jsonConfig.setJsonPropertyFilter(new PropertyFilter() {
	    public boolean apply(Object obj, String name, Object value) {
		if(obj instanceof Authorization||name.equals("authorization")){	
			return true;
		}else{
			return false;
		}
	   }
	});
	
	
	JSONObject jsonObject = JSONObject.fromObject(newBook,jsonConfig);
	try {
		response.getWriter().print(jsonObject);
	} catch (IOException e) {
		throw new RuntimeException(e.getMessage());
	}
	return null;
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:34,代码来源:BookManageAction.java

示例11: findReaderByPage

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
/**
 * 根据页码查询读者
 * @return
 */
public String findReaderByPage(){
	//获取页面传递过来的当前页码数
	if(pageCode==0){
		pageCode = 1;
	}
	//给pageSize,每页的记录数赋值
	int pageSize = 5;
	PageBean<Reader> pb = readerService.findReaderByPage(pageCode,pageSize);
	if(pb!=null){
		pb.setUrl("findReaderByPage.action?");
	}
	//存入request域中
	ServletActionContext.getRequest().setAttribute("pb", pb);
	return  "success";
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:20,代码来源:ReaderManageAction.java

示例12: addReaderType

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
public String addReaderType(){
	ReaderType readerType = new ReaderType();
	readerType.setReaderTypeName(readerTypeName);
	readerType.setPenalty(penalty);
	readerType.setMaxNum(maxNum);
	readerType.setBday(bday);
	readerType.setRenewDays(renewDays);
	boolean b = readerTypeService.addReaderType(readerType);
	int success = 0;
	if(b){
		success = 1;
	}
	try {
		ServletActionContext.getResponse().getWriter().print(success);//向浏览器响应是否成功的状态码
	} catch (IOException e) {
		// TODO Auto-generated catch block
		throw new RuntimeException(e.getMessage());
	}
	return null;
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:21,代码来源:ReaderTypeManageAction.java

示例13: deleteReader

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
/**
 * 删除指定管理员
 * @return
 */
public String deleteReader(){
	//删除读者需要注意的点:如果该读者有尚未归还的书籍或者尚未缴纳的罚款,则不能删除
	Reader reader = new Reader();
	reader.setReaderId(readerId);
	int success = readerService.deleteReader(reader);

	try {
		ServletActionContext.getResponse().getWriter().print(success);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		throw new RuntimeException(e.getMessage());
	}
	
	return null;
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:20,代码来源:ReaderManageAction.java

示例14: 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;
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:16,代码来源:TArticle.java

示例15: findBackInfoByPage

import org.apache.struts2.ServletActionContext; //导入依赖的package包/类
public String findBackInfoByPage(){
	
	//获取页面传递过来的当前页码数
	if(pageCode==0){
		pageCode = 1;
	}
	//给pageSize,每页的记录数赋值
	int pageSize = 5;
	
	PageBean<BackInfo> pb = backService.findBackInfoByPage(pageCode,pageSize);
	if(pb!=null){
		pb.setUrl("findBackInfoByPage.action?");
	}
	//存入request域中
	ServletActionContext.getRequest().setAttribute("pb", pb);
	return  "success";
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:18,代码来源:BorrowSearchAction.java


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