⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savelogoaction.java

📁 ajax+jsp打造的Blog源码,运行环境:eclipse+tomcat5.5
💻 JAVA
字号:
package cn.com.blogonline;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.jspsmart.upload.SmartUpload;


public class SaveLogoAction extends HttpServlet {
    
	private ServletConfig config;
	
	public void init(ServletConfig config) throws ServletException {
		this.config = config;
    }
    
    /*
     *  处理<GET> 请求方法.
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        /*
         * 上传文件
         */
		String imageName = null;
		SmartUpload mySmartUpload = new SmartUpload();
		try {
			// 初始化
			mySmartUpload.initialize(config,request,response);
			// 上载
			mySmartUpload.upload();
			// 保存上载文件到指定目录
			mySmartUpload.save("\\images");
			imageName = mySmartUpload.getFiles().getFile(0).getFileName();

		} catch (Exception e){
			System.out.println(e);
		}
		
       /*
        * 保存信息
        */
		HttpSession session = request.getSession(true);
		Blog blog = (Blog)session.getAttribute(Constants.LOGIN_USER_KEY);
		blog.setImage(imageName);
	    
		DbOperate	db=new DbOperate();
		db.update(blog);
		session.setAttribute(Constants.MODIFY_OK_KEY,new Integer(1));
		response.sendRedirect("/BlogOnline/adminLogo.jsp");
    }

	protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
		// TODO 自动生成方法存根
		this.doGet(arg0,arg1);
	}
    
    
}

⌨️ 快捷键说明

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