forumservlet.java

来自「社区文章采用的是平板、树形自由选择的两种展示方式」· Java 代码 · 共 73 行

JAVA
73
字号
/* 
 * Created on 2007-2-17
 * Last modified on 2007-7-27
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.club.controller.servlet;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yeqiangwei.club.controller.action.ForumAction;
import com.yeqiangwei.club.util.MessageUtils;
import com.yeqiangwei.club.view.util.UrlUtils;
import com.yeqiangwei.club.view.util.UserSetUtils;
import com.yeqiangwei.util.HttpServletUtils;
import com.yeqiangwei.util.Validator;

//import com.yeqiangwei.club.controller.action.ForumAction;
import com.yeqiangwei.util.ParamUtils;

public class ForumServlet extends HttpServlet {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private ForumAction forumAction;

	public void doGet(HttpServletRequest request, HttpServletResponse response){
		String act = ParamUtils.getStringParameter(request,"act");
		if(act.equals("style")){
			String style = UserSetUtils.find(request,UserSetUtils.FORUM_STYLE);
			request.setAttribute("forumId",ParamUtils.getStringParameter(request,"forumId"));
			if(style==null||style.equals("0")){
				UserSetUtils.update(request,response,UserSetUtils.FORUM_STYLE,"1");
			}else{
				UserSetUtils.update(request,response,UserSetUtils.FORUM_STYLE,"0");
			}
			HttpServletUtils.redirect(response
					,UrlUtils.getUrl(UrlUtils.FORUM
							,ParamUtils.getIntParameter(request,"forumId"),0,request));
		}
		else if(act.equals("doFavorite")){
			this.getForumAction().doFavorite(request,response);
		}
		else if(act.equals("delFavorite")){
			this.getForumAction().delFavorite(request,response);
		}
	}
	
	public void doPost(HttpServletRequest request
			,HttpServletResponse response) {
		response.setContentType("text/HTML;charset=UTF-8"); 
		String act = ParamUtils.getStringParameter(request,"act");
		if(act.equals("addLabel")){
			this.getForumAction().createLabel();
		}
		request.setAttribute("message",MessageUtils.getMessage("error_notfind"));
		HttpServletUtils.forward(request,response,"/club/msg.jsp");
		return;
	}

	public ForumAction getForumAction() {
		if(Validator.isEmpty(forumAction)){
			forumAction = new ForumAction();
		}
		return forumAction;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?