📄 logo.java
字号:
package com.opensource.blog.web.action;
import javax.servlet.http.*;
import org.apache.commons.lang.*;
import org.apache.struts.action.*;
import com.opensource.blog.exception.*;
import com.opensource.blog.model.*;
import com.opensource.blog.service.*;
import com.opensource.blog.service.cache.app.*;
import com.opensource.blog.web.form.*;
import com.opensource.blog.web.servlet.*;
public class Logo
extends BaseAction {
private BlogService blogService;
private BlogCache blogCache;
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm,
HttpServletRequest servletRequest,
HttpServletResponse servletResponse) {
ActionMessages errors = new ActionMessages();
LogoForm form = (LogoForm) actionForm;
UserSession us = this.getUserSession(servletRequest);
if (form.getAction().equalsIgnoreCase("up")) {
form.setAction("updo");
String url = "";
if (StringUtils.isBlank(us.getBlog().getLogourl())) {
url = "http://";
}
else {
url = us.getBlog().getLogourl();
}
form.setLogourl(url);
return actionMapping.findForward("logo");
}
if (form.getAction().equalsIgnoreCase("updo")) {
Blog blog = us.getBlog();
blog.setLogourl(form.getLogourl());
try {
blog = this.getBlogService().saveBlog(blog);
}
catch (BlogException ex) {
errors.add("error.blogblog.upinfo", new ActionMessage("error.blogblog.upinfo"));
saveErrors(servletRequest, errors);
return actionMapping.findForward("error");
}
this.saveUserSession(servletRequest, blog);
this.getBlogCache().removeFromCache(blog.getUsername());
ActionForward f = new ActionForward("/blogInfoHigh.do", true);
return f;
}
if (form.getAction().equalsIgnoreCase("del")) {
Blog blog = us.getBlog();
blog.setLogourl("");
try {
blog = this.getBlogService().saveBlog(blog);
}
catch (BlogException ex) {
errors.add("error.blogblog.upinfo", new ActionMessage("error.blogblog.upinfo"));
saveErrors(servletRequest, errors);
return actionMapping.findForward("error");
}
this.saveUserSession(servletRequest, blog);
this.getBlogCache().removeFromCache(blog.getUsername());
ActionForward f = new ActionForward("/blogInfoHigh.do", true);
return f;
}
return actionMapping.findForward("error");
}
public BlogService getBlogService() {
return blogService;
}
public BlogCache getBlogCache() {
return blogCache;
}
public void setBlogService(BlogService blogService) {
this.blogService = blogService;
}
public void setBlogCache(BlogCache blogCache) {
this.blogCache = blogCache;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -