由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Spring + Jersey 的 REST API, servlet context 能看到 Spring (转载)
相关主题
运行servlet时出现的http status 404问题JSP tag file and EL warnings
URL 的问题怎么解决?still web.xml question
spring webapplication context initialization hook ?求助!Tomcat下设置servlets的问题
问个RESTful的问题,简单的hello显示404错误大家都是怎么自学J2EE的
有没有人熟悉tomcat?急!spring mvc 里面 view 必须是 jsp吗?
eclipse的jetty服务started但8080口显示404 errorservlet-mapping causing http 404 error
Run Servlet with TomcatHow does a client find and connect to a specific
[转载] Urgent Help needed about Java Servlet?anyone use org.gxos package?
相关话题的讨论汇总
话题: param话题: servlet话题: context话题: name话题: spring
进入Java版参与讨论
1 (共1页)
t**********s
发帖数: 930
1
【 以下文字转载自 Programming 讨论区 】
发信人: tennisalways (tennisforever), 信区: Programming
标 题: Spring + Jersey 的 REST API, servlet context 能看到 Spring 的 root application context 里的bean吗?
发信站: BBS 未名空间站 (Fri Oct 9 17:57:56 2015, 美东)
比如这样的 web.xml

contextConfigLocation
/WEB-INF/root-context.xml



org.springframework.web.context.ContextLoaderListener



REST-V1
com.sun.jersey.spi.spring.container.servlet.SpringServlet


contextConfigLocation
/WEB-INF/context-v1.xml

1


REST-V2
com.sun.jersey.spi.spring.container.servlet.SpringServlet


contextConfigLocation
/WEB-INF/context-v2.xml

2

context-v1.xml 和 context-v2.xml 里都必须 />
否则调用root context 里的bean都会出现 NPE.
可是如果, 那么root context 里的bean就会
生成三次(root-context, context-v1, context-v2)
这是轮子设计的问题吗?还是我哪错了?
F****n
发帖数: 3271
2
Spring beans are normally singletons so multiple instances of same contexts
should be OK. (If it is not OK, 99% of time it is because your beans have
some design problem)
There are ways to share runtime contexts, but it increases the complexity of
your apps and makes them more error-prone. Not worth the effort.

application context 里的bean吗?

【在 t**********s 的大作中提到】
: 【 以下文字转载自 Programming 讨论区 】
: 发信人: tennisalways (tennisforever), 信区: Programming
: 标 题: Spring + Jersey 的 REST API, servlet context 能看到 Spring 的 root application context 里的bean吗?
: 发信站: BBS 未名空间站 (Fri Oct 9 17:57:56 2015, 美东)
: 比如这样的 web.xml
:
: contextConfigLocation
: /WEB-INF/root-context.xml
:

:

1 (共1页)
进入Java版参与讨论
相关主题
anyone use org.gxos package?有没有人熟悉tomcat?急!
帮忙看看. Get context variableeclipse的jetty服务started但8080口显示404 error
我土,怎么得到context root的完整url?Run Servlet with Tomcat
看到一个让我~!@#$%^&*的code[转载] Urgent Help needed about Java Servlet?
运行servlet时出现的http status 404问题JSP tag file and EL warnings
URL 的问题怎么解决?still web.xml question
spring webapplication context initialization hook ?求助!Tomcat下设置servlets的问题
问个RESTful的问题,简单的hello显示404错误大家都是怎么自学J2EE的
相关话题的讨论汇总
话题: param话题: servlet话题: context话题: name话题: spring