##spring bean对象request字段自动注入javax.servlet.ServletRequest
对象里面request全局变量是否线程安全呢?
答案:线程安全
##代码如下
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.ServletRequest;
@Controller
@RequestMapping("/mi")
public class YymController {
public YymController() {
System.out.println("yym");
}
@Autowired
private ServletRequest request;
@RequestMapping("/tomcatRequest")
@ResponseBody
public String tomcatRequest() {
String yym = request.getParameter("yym");
return yym;
}
}
##源码
##和当前线程绑定,线程安全