我刚开始使用http://viralpatel.net并且目前在Spring 3 MVC: Tiles Plugin Tutorial
时遇到问题我已经搜索了google和stackoverflow以获得解决方案,并且如果这是重复的话,找不到一个这样的appoligies。
当我尝试运行上述教程中的代码时,我在浏览器中遇到以下404错误
HTTP Status 404 - /Spring3MVC/WEB-INF/jsp/layout.jsp
但我没有控制台错误:
01-Nov-2012 13:37:32 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\jre1.6.0.33\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\oraclexe\app\oracle\product\11.2.0\server\bin;;C:\Windo
ws\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common F
iles\Intel\WirelessCommon\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Progra
m Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Enterprise Vault\EVClient\;C:\Program Files (x86)\Microsoft Office 2010\Office14;C:\
Program Files (x86)\QuickTime\QTSystem\;C:\Python27\;C:\Python27\Tools\Scripts\;C:\Program Files\Java\jre1.6.0.33\bin;C:\Program Files\maven-2.2.1\bin
;.
01-Nov-2012 13:37:32 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Spring3MVC' did not find a m
atching property.
01-Nov-2012 13:37:32 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
01-Nov-2012 13:37:32 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 533 ms
01-Nov-2012 13:37:32 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
01-Nov-2012 13:37:32 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.36
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
01-Nov-2012 13:37:33 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring'
01-Nov-2012 13:37:33 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
01-Nov-2012 13:37:33 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
01-Nov-2012 13:37:33 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/27 config=null
01-Nov-2012 13:37:33 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1637 ms
这是我的web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Spring3MVC</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
这是我的spring-servlet.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan
base-package="net.viralpatel.spring3.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles2.TilesView
</value>
</property>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
</beans>
这是我的tiles.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="base.definition"
template="/WEB-INF/jsp/layout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
<put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
</definition>
<definition name="contact" extends="base.definition">
<put-attribute name="title" value="Contact Manager" />
<put-attribute name="body" value="/WEB-INF/jsp/contact.jsp" />
</definition>
</tiles-definitions>
代码的其余部分是上面教程的精确副本,它基于handling forms tutorial构建,我似乎已经完美地工作了。下面是eclipse项目的屏幕抓取,包括罐子,以防有人认为这可能是一个丢失或错误的罐子的问题
非常感谢任何帮助/建议/指示。
答案 0 :(得分:1)
这可能是问题
在tiles.xml中,layout.jsp URL为
/WEB-INF/jsp/layout.jsp
你的jsp文件夹是
WebContent/jsp/