我只有一个应用程序上下文文件tradelc-servlet.xml。所以我认为不需要ContextLoaderListener。但我仍然得到标题中提到的例外
ClsEditBody.jsp
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="logic" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/WEB-INF/tlc.tld" prefix="tlc" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%
String titleKey="crp.cls.title." + request.getParameter("action");
%>
<c:set var="action">
<%= (String)request.getParameter("action") %>
</c:set>
<tlc:in parameter="action" value="modify;create">
<form:form>
<form:hidden path="ukey" />
.
.
.
.
的web.xml
<!--CharsetFilter start-->
<filter>
<filter-name>Charset Filter</filter-name>
<filter-class>com.bankofny.inx.omx.lc.web.action.CharsetFilter</filter-class>
<init-param>
<param-name>characterEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Charset Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--CharsetFilter end-->
<listener>
<listener-class>com.bankofny.inx.omx.lc.web.util.SessionListener</listener-class>
</listener>
<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>tradelc</servlet-name>
<!-- Specify servlet class to use:
- Struts1.0.x: ActionComponentServlet
- Struts1.1: ActionServlet
- no Struts: TilesServlet
-->
<!-- <servlet-class>org.apache.struts.tiles.ActionComponentServlet</servlet-class> -->
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- <servlet-class>com.bankofny.inx.omx.lc.web.action.DevlActionServlet</servlet-class> -->
<!-- <servlet-class>org.apache.struts.tiles.TilesServlet</servlet-class> -->
<!-- Tiles Servlet parameter
Specify configuration file names. There can be several comma
separated file names
-->
<init-param>
<param-name>definitions-config</param-name>
<param-value>/WEB-INF/tiles-defs.xml</param-value>
</init-param>
<!-- Tiles Servlet parameter
Specify Tiles debug level.
O : no debug information
1 : debug information
2 : more debug information
-->
<init-param>
<param-name>definitions-debug</param-name>
<param-value>1</param-value>
</init-param>
<!-- Tiles Servlet parameter
Specify Digester debug level. This value is passed to Digester
O : no debug information
1 : debug information
2 : more debug information
-->
<init-param>
<param-name>definitions-parser-details</param-name>
<param-value>0</param-value>
</init-param>
<!-- Tiles Servlet parameter
Specify if xml parser should validate the Tiles configuration file.
true : validate. DTD should be specified in file header.
false : no validation
-->
<init-param>
<param-name>definitions-parser-validate</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>tradelc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>21</session-timeout>
</session-config>
<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<exception-type>com.bankofny.inx.omx.lc.web.exceptions.LockException</exception-type>
<location>/errors/LockError.jsp</location>
</error-page>
<!-- Struts Tag Library Descriptor -->
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</web-app>
tradelc-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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<context:annotation-config />
<!-- Scans within the base package of the application for @Components to configure-->
<context:component-scan base-package="com.bankofny.inx.omx.lc.web.actions" />
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="resources.application" />
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
例外:
org.apache.jasper.JasperException: An exception occurred processing JSP page /cls/ClsEdit.jsp at line 12
org.apache.jasper.JasperException: An exception occurred processing JSP page /cls/ClsEditBody.jsp at line 17
14:
15:
16: <tlc:in parameter="action" value="modify;create">
17: <form:form>
18: <form:hidden path="ukey" />
19: <!-- OMX00003517 UAT: June 2009: Invalid Password JavaScript Issue Start -->
20: <input type="hidden" name="password1" value="">
堆栈跟踪:
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:89)
org.springframework.web.servlet.support.RequestContextUtils.getWebApplicationContext(RequestContextUtils.java:89)
org.springframework.web.servlet.support.RequestContext.initContext(RequestContext.java:237)
org.springframework.web.servlet.support.JspAwareRequestContext.initContext(JspAwareRequestContext.java:74)
org.springframework.web.servlet.support.JspAwareRequestContext.<init>(JspAwareRequestContext.java:48)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
org.apache.jsp.cls.ClsEditBody_jsp._jspx_meth_form_005fform_005f0(ClsEditBody_jsp.java:241)
org.apache.jsp.cls.ClsEditBody_jsp._jspx_meth_tlc_005fin_005f0(ClsEditBody_jsp.java:214)
org.apache.jsp.cls.ClsEditBody_jsp._jspService(ClsEditBody_jsp.java:155)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:954)
org.apache.jsp.cls.ClsEdit_jsp._jspService(ClsEdit_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
com.bankofny.inx.omx.lc.web.action.CharsetFilter.doFilter(CharsetFilter.java:45)
答案 0 :(得分:1)
在web.xml中声明ContextLoaderListener,这是强制性的!