[英]Spring3 - using Views from parent project- getting 404
I have a parent "base" project (jar) which contains controllers with their corresponding views. 我有一个父级“基础”项目(jar),其中包含带有相应视图的控制器。
In my child project (war), I have a dependency on this parent project in my pom.xml and "import" the parents application context in the childs application context, however when I start the web app, I get a 404 on /views/index.jsp. 在我的子项目(战争)中,我在pom.xml中对此父项目有依赖性,并在子应用程序上下文中“导入”父应用程序上下文,但是,当我启动Web应用程序时,在/ views上得到404 /index.jsp。
How am i able to get my child war project to know about the parents views, the controllers are all working as expected with the use of annotations. 我如何使我的孩子大战项目了解父母的观点,控制器都通过使用注释按预期工作。
I get a 404 on /views/index.jsp, i guess this is because its looking in my child project (war) for the views, where as they are in the parent project... 我在/views/index.jsp上得到404,我想这是因为它在我的子项目(war)中寻找视图,就像它们在父项目中一样。
Code samples below: 下面的代码示例:
applicationContext-parent.xml 的applicationContext-parent.xml
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
View files are kept in parent under /src/main/resources/views 视图文件保存在/ src / main / resources / views下的父文件中
applicationContext-child.xml 的applicationContext-child.xml
<beans>
// some other stuff
<import resource="classpath:applicationContext-parent.xml" />
// more stuff
</beans>
Found the answer after much searching... 经过大量搜索后找到了答案...
Its detailed here: enter link description here 其详细信息在这里:在此处输入链接描述
In essense... "Have a look at the maven war plugin. This plugin allows what it calls overlays. 本质上来说,“看一下maven war插件。这个插件允许它称之为叠加层。
Overlays are used to share common resources across multiple web applications. 覆盖图用于在多个Web应用程序之间共享公共资源。 The dependencies of a WAR project are collected in WEB-INF/lib, except for WAR artifacts which are overlayed on the WAR project itself." WAR项目的依赖项收集在WEB-INF / lib中,除了WAR工件本身覆盖在WAR项目本身上。”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.