本文整理汇总了Java中javax.servlet.ServletRequestEvent.getServletContext方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRequestEvent.getServletContext方法的具体用法?Java ServletRequestEvent.getServletContext怎么用?Java ServletRequestEvent.getServletContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.ServletRequestEvent
的用法示例。
在下文中一共展示了ServletRequestEvent.getServletContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestInitialized
import javax.servlet.ServletRequestEvent; //导入方法依赖的package包/类
@Override
public void requestInitialized(ServletRequestEvent sre) {
ServletContext servletContext = sre.getServletContext();
ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
GroovyClassLoader classLoader = applicationContext.getBean(GroovyClassLoader.class);
if (Thread.currentThread().getContextClassLoader() instanceof GroovyClassLoader) {
} else {
Thread.currentThread().setContextClassLoader(classLoader);
}
DataSource dataSource = applicationContext.getBean(DataSource.class);
try {
this.connection = dataSource.getConnection();
this.connection.setAutoCommit(true);
} catch (SQLException e) {
}
}
示例2: requestInitialized
import javax.servlet.ServletRequestEvent; //导入方法依赖的package包/类
@Override
public void requestInitialized(ServletRequestEvent sre) {
//System.out.println("Requset 初始化了:" + sre.getServletRequest());
ServletContext ctx = sre.getServletContext();
exector.execute(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
Integer count = (Integer) ctx.getAttribute(BookStoreConstants.REQUEST_COUNT); // 获得list
if (count == null) {
count = 0;
}
ctx.setAttribute(BookStoreConstants.REQUEST_COUNT, count+1);
}
});
}
示例3: requestInitialized
import javax.servlet.ServletRequestEvent; //导入方法依赖的package包/类
@Override
public void requestInitialized(ServletRequestEvent requestEvent) {
if (!(requestEvent.getServletRequest() instanceof HttpServletRequest)) {
logger.debug("error type: " + requestEvent.getServletRequest().getClass().getName());
throw new IllegalArgumentException("Request is not an HttpServletRequest: " + requestEvent.getServletContext());
}
HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest();
GlobalServiceImpl.setUpHttpSession(request);
}
示例4: requestInitialized
import javax.servlet.ServletRequestEvent; //导入方法依赖的package包/类
public void requestInitialized(ServletRequestEvent sre) {
ServletRequest request = sre.getServletRequest();
ServletContext context = sre.getServletContext();
if(request!=null&&context!=null)
request.setAttribute(LocaleUtils.LOCALE_RESOLVER_ATTRIBUTE, context.getAttribute(LocaleUtils.LOCALE_RESOLVER_NAME));
}
示例5: requestInitialized
import javax.servlet.ServletRequestEvent; //导入方法依赖的package包/类
@Override
public void requestInitialized(ServletRequestEvent sre) {
Map<String, String[]> paramMap = sre.getServletRequest().getParameterMap();
ServletContext servletContext = sre.getServletContext();
// to see log messages at runtime, check the terminal window where you started JBoss AS.
servletContext
.log("ParameterDumpingRequestListener: request has been initialized. It has " + paramMap.size() + " parameters:");
for (Map.Entry<String, String[]> entry : paramMap.entrySet()) {
for (String val : entry.getValue()) {
servletContext.log(" " + entry.getKey() + "=" + val);
}
}
}
示例6: requestInitialized
import javax.servlet.ServletRequestEvent; //导入方法依赖的package包/类
@Override
public void requestInitialized(ServletRequestEvent sre) {
Map<String, String[]> paramMap = sre.getServletRequest().getParameterMap();
ServletContext servletContext = sre.getServletContext();
// to see log messages at runtime, check the terminal window where you started JBoss AS.
servletContext.log("ParameterDumpingRequestListener: request has been initialized. It has " + paramMap.size()
+ " parameters:");
for (Map.Entry<String, String[]> entry : paramMap.entrySet()) {
for (String val : entry.getValue()) {
servletContext.log(" " + entry.getKey() + "=" + val);
}
}
}