其他分享
首页 > 其他分享> > SpringMVC是如何处置线程安全

SpringMVC是如何处置线程安全

作者:互联网

5.线程安全


一般情况下,@Controller是单例的,和Servlet那时是一样的,参见我的Servlet的第二章处理线程安全的问题。
例5.1:
package com;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.ServletConfigAware;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.support.RequestContextUtils;
import com.jspsmart.upload.File;
import com.jspsmart.upload.Files;
import com.jspsmart.upload.SmartUpload;
import com.jspsmart.upload.SmartUploadException;
@Controller
public class HelloWorldController implements ServletConfigAware,ServletContextAware {
    private ServletContext servletContext;  
    @Override  
    public void setServletContext(ServletContext arg0) {  
        this.servletContext = arg0;  
    }  
    private ServletConfig servletConfig;  
    @Override  
    public void setServletConfig(ServletConfig arg0) {  
        this.servletConfig = arg0;  
    }            


更多内容请见原文,文章转载自:https://blog.csdn.net/qq_44639795/article/details/103202378

标签:处置,web,SpringMVC,springframework,线程,import,org,servlet,javax
来源: https://www.cnblogs.com/malala/p/15783370.html