Announcement Announcement Module
Collapse
No announcement yet.
about spring taglib's question ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • about spring taglib's question ?

    i'm not good at English.
    I appends <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> in a jsp.when preview,appear error!

    Code:
    java.lang.IllegalStateException&#58; No WebApplicationContext found&#58; no ContextLoaderListener registered?
    	org.springframework.web.servlet.support.RequestContextUtils.getWebApplicationContext&#40;RequestContextUtils.java&#58;82&#41;
    	org.springframework.web.servlet.support.RequestContext.initContext&#40;RequestContext.java&#58;203&#41;
    	org.springframework.web.servlet.support.JspAwareRequestContext.initContext&#40;JspAwareRequestContext.java&#58;74&#41;
    	org.springframework.web.servlet.support.JspAwareRequestContext.<init>&#40;JspAwareRequestContext.java&#58;48&#41;
    	org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag&#40;RequestContextAwareTag.java&#58;65&#41;
    	org.apache.jsp.jsp.register_jsp._jspService&#40;register_jsp.java&#58;79&#41;
    	org.apache.jasper.runtime.HttpJspBase.service&#40;HttpJspBase.java&#58;94&#41;
    	javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    	org.apache.jasper.servlet.JspServletWrapper.service&#40;JspServletWrapper.java&#58;324&#41;
    	org.apache.jasper.servlet.JspServlet.serviceJspFile&#40;JspServlet.java&#58;292&#41;
    	org.apache.jasper.servlet.JspServlet.service&#40;JspServlet.java&#58;236&#41;
    	javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    why,please?

    my jsp
    Code:
    <%@ taglib prefix="spring" uri="http&#58;//www.springframework.org/tags" %>
    <%@ taglib prefix="c" uri="http&#58;//java.sun.com/jstl/core_rt"%>
    <%@ page pageEncoding="gb2312" contentType="text/html;charset=gb2312"%>
    <html>
    <head>
    <title>user</title> &#58;&#40; 
    </head>
    <body style="text-align&#58;center">
    	<form method='post' action="/register.do">
    		<spring&#58;bind path="command.*" >
    			<font color='#FF0000'>
    				<c&#58;forEach 
    					items="$&#123;status.errorMessages&#125;"
    					var="error">
    						error:<c&#58;out value="$&#123;error&#125;" ></c&#58;out><br>
    				</c&#58;forEach>
    			</font>
    
    		</spring&#58;bind>
    
    		<table border="0" width="450" height="101" cellspacing="0" cellpadding="0">
    			<tr>
    				<td heigth="27" width="408" colspan="2">
    					<p align="center"><b>registe</p></td>
    				</td>
    			</tr>
    			<tr>
    				<td heigth="23" width="104">username:</td>
    				<td heigth="23" width="450">
    					<spring&#58;bind path="command.username" >
    					<input type="text" name="username"
    					value="<c&#58;out value="$&#123;status.value&#125;"/>"
    					name="<c&#58;out value="$&#123;status.expression&#125;"/>">
    					<br>
    					<c&#58;if test="$&#123;status.error&#125;">
    						<font color="#FF0000">
    							error:
    							<c&#58;forEach 
    								items="$&#123;status.errorMessages&#125;"
    								var="error">
    								<c&#58;out value="$&#123;error&#125;"/>
    							</c&#58;forEach>
    						</font>
    					</c&#58;if>
    					</spring&#58;bind>
    				</td>
    				</td>
    			</tr>
    			<tr>
    				<td height="23" width="104">password_1:</td>
    				<td height="23" width="450">
    					<spring&#58;bind path="command.password1" >
    						<input
    						type="password" name="password1"
    						value="<c&#58;out value="$&#123;status.value&#125;"/>"
    						name="<c&#58;out value="$&#123;Status.expression&#125;"/>">
    						
    						<br>
    						<c&#58;if test="$&#123;status.error&#125;">
    							<font color="#FF0000">
    							error:
    							<c&#58;forEach 
    								items="$&#123;status.errorMessages&#125;"
    								var="error">
    								<c&#58;out value="$&#123;error&#125;" ></c&#58;out>
    							</c&#58;forEach>
    							</font>
    						</c&#58;if>
    			   			
    
    					</spring&#58;bind>
    			</td>
    		
    			</tr>
    			<tr>
    			<td height="23" width="104" >password_2:</td>
    			<td height="23" width="450">
    				<spring&#58;bind path="command.password2" >
    					<input type="password" 
    					name="password2"
    					value="<c&#58;out value="$&#123;status.value&#125;"/>"
    					name="<c&#58;out value="$&#123;status.expression&#125;"/>"
    					>
    					<br>
    					<c&#58;if test="$&#123;status.error&#125;">
    						<font color="#FF0000">
    							error:
    							<c&#58;forEach 
    								items="$&#123;status.errorMessages&#125;"
    								var="error">
    								<c&#58;out value="$&#123;error&#125;"/>
    							</c&#58;forEach>
    						</font>
    					</c&#58;if>
    				</spring&#58;bind>
    			</td>
    			
    			</tr>
    		</table>
    		<p>
    			<input type="submit" value="submit" name="B1">
    			<input type="reset" value="reset" name="B2">
    		
    		</p>
    
    	</form>
    </body>
    
    </html>

  • #2
    Can you post the bit of the web.xml where you register the ContextLoaderListener? It should look something like:
    Code:
    	<servlet>
    		<servlet-name>context</servlet-name>
    		<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    or for servlet 2.4 (preferred method):
    Code:
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>

    Comment


    • #3
      my web.xml
      Code:
      <?xml version="1.0" ?>
      <web-app xmlns="http&#58;//java.sun.com/xml/ns/j2ee"
          xmlns&#58;xsi="http&#58;//www.w3.org/2001/XMLSchema-instance"
          xsi&#58;schemaLocation="http&#58;//java.sun.com/xml/ns/j2ee http&#58;//java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
          version="2.3">
      
      <!-- Copyright &#40;c&#41; 2002 by ObjectLearn. All Rights Reserved. -->
      
      	<welcome-file-list>
      		<welcome-file>index.jsp</welcome-file>
      	</welcome-file-list>
      
      	<error-page>
      		<error-code>404</error-code>
      		<location>/error.jsp</location>
      	</error-page>
      
      
      	<servlet>
      		<servlet-name>reg</servlet-name>
      		<servlet-class>
      			org.springframework.web.servlet.DispatcherServlet
      		</servlet-class>
      		<init-param>
      			<param-name>contextConfigLocation</param-name>
      			<param-value>/WEB-INF/regcofig.xml</param-value>
      		</init-param>
      		
      	</servlet>
      	
      	<servlet-mapping>
      		<servlet-name>reg</servlet-name>
      		<url-pattern>*.do</url-pattern>
      	</servlet-mapping>
      
      </web-app>
      my regcofig.xml
      Code:
      <?xml version="1.0" ?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
      
       <beans>
       
       <beans>
      
       	<!--Definition of View Resolver-->
       	 <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
              <property name="viewClass">
                 <value>org.springframework.web.servlet.view.JstlView</value>
              </property>
              <property name="prefix"><value>/jsp/</value></property>
              <property name="suffix"><value>.jsp</value></property>
          </bean>
      
       	<bean id="RegisterValidator" 
       		class="net.xia.validator.RegisterValidator"/>
      
       	<!--Action Definition-->
       	<bean id="RegisterAction"
       		class="net.xia.action.RegisterAction">
       		
       	<property name="commandName">
       		<value>RegisterInfo</value>
       	</property>	
       		
       	<property name="commandClass">
       		<value>net.xia.validator.RegisterInfo</value>
       	</property>
       	
       	<property name="validator">
       		<ref bean="RegisterValidator"/>
       	</property>
       	
       	<property name="formView">
       		<value>register</value>
       	</property>
       	<property name="successView">
       		<value>registersuccess</value>
       	</property>
       	</bean>
       	
       	<!--Request Mapping-->
       	<bean id="urlMapping"
       		class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
       	<property name="mappings">
       		<props>
       			<prop key="/register.do">RegisterAction</prop>
       			
       		</props>
       	</property>
       	</bean>
       	
       </beans>

      Comment


      • #4
        ???why?

        Comment


        • #5
          Your web.xml doesn't appear to be valid. The version="2.3" should be version="2.4"

          Comment


          • #6
            Thanks for helping me!

            Comment

            Working...
            X