小编Hum*_*ing的帖子

Spring - 应用程序初始化两次?

当我开始运行我的春天应用程序我的tomcat时,会ContextRefreshedEvent发生两次火灾.请参阅StackTrace.

Dec 20, 2013 6:07:56 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:SpringValidations' did not find a matching property.
Dec 20, 2013 6:07:56 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;F:\sub\svn\bin;%DERBY_HOME%\bin;D:\Lal\Lab\SW\apache-maven-3.0.4/bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.6.0_25\bin;;F:\Eclipse\sts-2.9.2.RELEASE;
Dec 20, 2013 6:07:56 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Dec 20, 2013 …
Run Code Online (Sandbox Code Playgroud)

java spring web-applications initialization spring-mvc

10
推荐指数
2
解决办法
2万
查看次数

contextstoppedevent vs contextclosedevent在春天?

任何人都可以解释一下我在spring中的contextstoppedevent和contextclosedevent之间有什么区别.

我认为他们是一样的,

ConfigurableApplicationContext sss = (ConfigurableApplicationContext) ((ApplicationContextEvent) event).getApplicationContext();
sss.stop();
sss.close();
Run Code Online (Sandbox Code Playgroud)

我可以知道在哪里使用以及何时使用它?

java spring event-handling

9
推荐指数
1
解决办法
5048
查看次数

如何在春季初始化应用程序?

现在直接来到我的观点,

JSP我将做我的应用程序的初始化过程,如,

<%! public void jsp_init(){

      //Initialise the domain server to create protocol
      //Create the logging file
}%>
Run Code Online (Sandbox Code Playgroud)

现在我打算从重建我以前的应用程序ServletsSpring 3.2.

我怎么能这样做Spring 3.2

我有一个人colleague说要做到这一点initialization with Constructor of the Spring Controller.

因为我已经创建了为豆controller classapplicationContext.xml和我加载的applicationContext.xml文件枝条ContextLoadListnerweb.xml.

这是正确的初始化方式吗?

春天的ApplicationListener怎么样 ?

哪个是初始化应用程序的最佳方法spring 3.2

希望我们的堆栈用户能给出一个好的解决方案

java spring jsp initialization spring-mvc

8
推荐指数
2
解决办法
2万
查看次数

如何为一个特定的servlet应用过滤器?

在聊天我的应用程序我有五个servlet.我需要为一个servlet应用过滤器.

我的过滤器是,

package com.tps.flexchat.action;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * Servlet Filter implementation class EncodingFilter
 */
public class EncodingFilter implements Filter {
    private String encoding = "UTF-8";
    private FilterConfig filterConfig;
    /**
     * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
     */
    public void init(FilterConfig filterConfig) throws ServletException {
        this.filterConfig = filterConfig;
    }

    /**
     * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
     */
    public void doFilter(ServletRequest req, ServletResponse resp,FilterChain chain) throws IOException, ServletException {

        resp.setCharacterEncoding("encoding");
        resp.setContentType("encoding");
                    req.setCharacterEncoding(encoding);
        chain.doFilter(req, resp);

        System.out.println("filter …
Run Code Online (Sandbox Code Playgroud)

java web.xml servlets servlet-filters

7
推荐指数
2
解决办法
4780
查看次数

Spring中会话过期的监听器

我是Spring的新手,并将其用于身份验证.我面临的一个问题是,当浏览器关闭或遇到任何异常故障时,会话过期但我无法捕获事件以便执行清理代码.我探讨一下,发现HttpSessionEventPublisher在春天捕获HttpSessionDestroyedEventsessionDestroyed()方法,但是当我关闭浏览器不叫.

请求建议相同的解决方案.

java session spring spring-security

7
推荐指数
1
解决办法
1万
查看次数

如何在Java中检查线程是否已经启动?

我有一个扩展Thread的类.

我会在某个时候开始这个帖子.

一段时间后,我需要检查该线程是否已经启动?

这样我就可以在那一点开始.

我的线程类是,

public class BasicChatListener extends Thread{

    public void run(){


    }

}
Run Code Online (Sandbox Code Playgroud)

我需要知道一个BasicChatListener类的特定线程是否正在运行?因为我的应用程序中已经有多个线程在运行.

我们的堆栈成员将如何帮助我.

java multithreading

6
推荐指数
1
解决办法
2万
查看次数

Spring MVC + Facelets,有可能吗?

我用JSP和Hibernate创建了一个Spring MVC项目,效果很好.现在我想使用Facelets而不是JSP.

我的想法是使用像PrimeFaces这样的Facelets作为视图而不是JSP,Spring MVC框架在中间,可能在后端使用Hibernate.

可能吗?如果是,我怎样才能实现这一目标?如果没有,为什么不呢?

jsf facelets spring-mvc

6
推荐指数
1
解决办法
5312
查看次数

Html vs JSP - 获取请求标头标记值

我正在研究Java应用程序.前端是Angular2.

如果我尝试打开我的应用程序主页( index.htmlweb.xml中配置为默认页面).访问URL应为 http:// localhost:8080/MyWebApp.

然后我进入了标准组织的登录页面进行身份验证.如果验证成功,将在请求标头中设置HTTP授权令牌,最后控件将显示我的应用程序主页.

如果我使用jsp,我可以获取请求标头,

String authHeader = request.getHeader("authorization");          
out.println("<h2>HTTP Authorization header:</h2>");

if (authHeader == null) {            
     out.print("No authorization header");      
} else {            
     out.print("<textarea readonly id='authHeader' rows=\"5\" cols=\"80\">" + authHeader + "</textarea>");
}
Run Code Online (Sandbox Code Playgroud)

但我们使用html作为前端,因为角度为2.

所以对于我的场景,我如何获得请求标头令牌.

如果不清楚,请不要犹豫,编辑我的问题.

html javascript java jsp angular

6
推荐指数
1
解决办法
1616
查看次数

使用 AspectJ 的 AOP 在 Spring 中不起作用?

我的方面课程将是,

@Configuration
@EnableAspectJAutoProxy
@Component
@Aspect
public class AspectClass {

    @Before("execution(* com.pointel.aop.test1.AopTest.beforeAspect())")
    public void logBefore(JoinPoint joinPoint) {

        System.out.println("Before running the beforeAspect() in the AopTest.java class!");
        System.out.println("Hijacked Method name : " + joinPoint.getSignature().getName());
        System.out.println("************************");
    }

}
Run Code Online (Sandbox Code Playgroud)

我的另一个java类

public class AopTest {

    public void beforeAspect() {
        System.out.println("This is beforeAspect() !");
    }
}
Run Code Online (Sandbox Code Playgroud)

我的主要课程是

public class MainMethod {

    public static void main(String[] args) {    
        ApplicationContext context = new FileSystemXmlApplicationContext("ApplicationContext/applicationContext.xml");
        AopTest test = (AopTest)context.getBean("bean1");
        test.beforeAspect();
    }
}
Run Code Online (Sandbox Code Playgroud)

我的 applicationContext.xml 是,

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" …
Run Code Online (Sandbox Code Playgroud)

java spring aspectj spring-aop spring-annotations

5
推荐指数
1
解决办法
3万
查看次数

模型属性存储在哪里?

我搜索了很多,却找不到答案。

模型对象值存储在中的位置Spring

model.addAttributes("key","values")被存储的值(例如:会话,请求)。什么是对这个范围有多大?

我如何使用expression languagelike 来获取JSP中存储值的值${key}

如何EL检索中的存储值model

java spring jsp servlets spring-mvc

5
推荐指数
1
解决办法
1649
查看次数