日期:2014-05-18 浏览次数:20620 次
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import org.activiti.engine.IdentityService;
import org.activiti.engine.identity.Picture;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
/**
* Servlet implementation class ShowPic
*/
@WebServlet("/ShowPic.slt")
public class ShowPicServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private IdentityService identityService;
/**
* @see HttpServlet#HttpServlet()
*/
public ShowPicServlet() {
super();
}
/*
* (非 Javadoc)
*
* @see javax.servlet.http.HttpServlet#service(javax.servlet.ServletRequest,
* javax.servlet.ServletResponse)
*/
@Override
public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
//通过spring配置初始化服务对象
ServletContext application = getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(application);// 获取spring的context
identityService = (IdentityService)wac.getBean("identityService");
Subject currentUser = SecurityUtils.getSubject();
Picture userPicture = identityService.getUserPicture(currentUser.getPrincipal().toString());