DispatcherPortlet을 사용하지 않고 Spring을 사용하여 포틀릿을 개발할 수있는 방법이 있습니까? 나는 UI를 위해 다른 기술, 주로 Vaadin을 사용하고 싶다. 봄은 DI와 다른 것들을 위해 사용됩니다. 포틀릿 측면에서 ContextLoaderListener 클래스와 비슷한 것이 있습니까?Spring MVC없이 포틀릿에서 Spring 사용하기
답변
나는 노엘이 준 것보다 더 자세한 대답을 원했습니다. 어쩌면 이것에 대한 모범 사례가 있을까요? 다음은 현재 솔루션입니다.
xml 파일 위치를 내 포틀릿의 초기화 매개 변수로 지정하십시오. 내 초기화 방법은 지금은 PortletContext을 통해 내가 필요로 할 때마다 내 ApplicationContext에 액세스 할 수 있습니다이
@Override
public void init(PortletConfig config) throws PortletException {
super.init(config);
String configLocations = config.getInitParameter("contextConfigLocation");
ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext();
springContext.setConfigLocation(configLocations);
springContext.refresh();
config.getPortletContext().setAttribute(APPLICATION_CONTEXT_ATTRIBUTE, springContext);
}
같은 것을 보인다.
(ApplicationContext) portalContext.getAttribute(APPLICATION_CONTEXT_ATTRIBUTE);
APPLICATION_CONTEXT_ATTRIBUTE는 내가 작성한 문자열 상수입니다. 나는 더 나은 해결책을 위해 아직 열려 있습니다.
는 the Spring documentation을 보면 다음과 같이 당신은 ApplicationContext
를 만들 수 있습니다
ApplicationContext context =
new ClassPathXmlApplicationContext(new String[] {"services.xml", "daos.xml"});
클래스 경로에 xml 파일을 참조하는.
그런 다음 context.getBean("beanName")
을 호출하여 콩을 가져올 수 있습니다. Spring MVC가 필요 없다.
:
의 ApplicationContext CTX = PortletApplicationContextUtils.getWebApplicationContext (getPortletContext());
그러면 web.xml에 구성을 추가하기 만하면됩니다.
PortletApplicationContextUtils를 사용하여 응용 프로그램 컨텍스트를 어떻게 초기화합니까? – palto
- 1. Eclipse에서 Spring IDE 사용하기 3.4
- 2. 기본 컨텍스트에서 Spring ContextLoaderListener 사용하기
- 3. WebLogic 10.3.4.0에서 Spring Console Extension 사용하기 Spring 3.0.3과 함께
- 4. MVC없이 Spring 3.0에서 RESTFUL 웹 서비스를 만들 수 있습니까?
- 5. Spring 3.0.0.RC1에서 @PostConstruct 어노테이션 사용하기
- 6. 통합 테스트를 위해 다른 Spring 속성 사용하기
- 7. Spring XML 설정 파일에서 프라퍼티 문자열 사용하기
- 8. Tomcat에서 Spring + Hibernate 트랜잭션 캐시 사용하기?
- 9. 석영 스케쥴러와 함께 Spring AOP 사용하기
- 10. Spring IOC를 MVP 패턴과 함께 사용하기
- 11. Spring @Value 시스템 속성을 Managed Bean으로 사용하기
- 12. Spring MVC와 Spring Web Flow의 차이점은 무엇입니까?
- 13. 리소스를 보호하기위한 Spring HandlerInterceptor 또는 Spring Security
- 14. Spring 2.0.7에 사용할 Spring Webservice 버전은 무엇입니까?
- 15. Alfresco의 spring surf vs classic spring mvc
- 16. Stripes + Spring vs Spring MVC의 단점
- 17. GWT + Spring
- 18. Spring Adotemplate.commandtimeout
- 19. Spring InitBinder
- 20. Spring FlashScope
- 21. Spring RuntimeBeanReference
- 22. Spring JdbcTemplate
- 23. Spring - jdbcTemplate
- 24. Seam과 Spring
- 25. Spring JmsTemplate + Security
- 26. Bean 수명을 관리하기 위해 여러 ApplicationContext를 생성하여 Spring 사용하기 - 괜찮습니까?
- 27. SiteMesh 2.4.2 + Spring MVC 3.0.4 - 다중 데코레이터 사용하기
- 28. 종속성을 클라이언트 응용 프로그램에 노출시키지 않고 Spring 사용하기
- 29. c3p0 연결 사용하기 Tomcat에서 풀링하기 Spring 기반 App
- 30. Spring 3에서 명령 객체 사용하기 GET 요청을 가진 @Controller
이 MVC 기반을 제외하고는 봄에 다른 포틀릿 구현이 없다고 생각합니다. 물론 우리는 noel 작성자로 직접 콩을 만들 수 있지만 포틀릿으로 처리하는 방법은 무엇입니까? – Parth