Announcement Announcement Module
Collapse
No announcement yet.
Error using spring tld in any jsp page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error using spring tld in any jsp page

    Code:
    <%@taglib prefix="c" uri="http&#58;//java.sun.com/jsp/jstl/core" %> 
    <%@taglib uri="http&#58;//www.springframework.org/tags" prefix="spring" %> 
    <%@page  contentType="text/html;charset=gb2312"%> 
    <html> 
    <head> 
    <title>用户注册</title> 
    </head> 
    <body> 
    </body> 
    </html>
    error:
    java.lang.IllegalStateException: No WebApplicationContext found: not in a DispatcherServlet request?
    org.springframework.web.servlet.support.RequestCon textUtils.getWebApplicationContext(RequestContextU tils.java:79)
    org.springframework.web.servlet.support.RequestCon textUtils.getWebApplicationContext(RequestContextU tils.java:56)
    org.springframework.web.servlet.support.RequestCon text.<init>(RequestContext.java:95)
    org.springframework.web.servlet.support.RequestCon text.<init>(RequestContext.java:81)
    org.springframework.web.servlet.tags.RequestContex tAwareTag.doStartTag(RequestContextAwareTag.java:6 7)
    org.apache.jsp.register_jsp._jspService(register_j sp.java:84)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

    my web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?> 
    <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.4"> 
      <display-name>test</display-name> 
      <context-param> 
        <param-name>contextConfigLocation</param-name> 
        <param-value>/WEB-INF/test-servlet.xml</param-value> 
        
      </context-param> 
      <servlet> 
        <servlet-name>context</servlet-name> 
        <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> 
        <load-on-startup>1</load-on-startup> 
      </servlet> 
      <servlet> 
        <servlet-name>test</servlet-name> 
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
        <load-on-startup>1</load-on-startup> 
      </servlet> 
      <servlet-mapping> 
        <servlet-name>test</servlet-name> 
        <url-pattern>*.htm</url-pattern> 
      </servlet-mapping> 
      <servlet-mapping> 
        <servlet-name>test</servlet-name> 
        <url-pattern>*.do</url-pattern> 
      </servlet-mapping> 
    
      <jsp-config> 
        <taglib> 
          <taglib-uri>http&#58;//java.sun.com/jsp/jstl/core</taglib-uri> 
          <taglib-location>/WEB-INF/c.tld</taglib-location> 
        </taglib> 
        <taglib> 
          <taglib-uri>http&#58;//java.sun.com/jsp/jstl/xml</taglib-uri> 
          <taglib-location>/WEB-INF/x.tld</taglib-location> 
        </taglib> 
        <taglib> 
          <taglib-uri>http&#58;//java.sun.com/jsp/jstl/fmt</taglib-uri> 
          <taglib-location>/WEB-INF/fmt.tld</taglib-location> 
        </taglib> 
        <taglib> 
          <taglib-uri>http&#58;//java.sun.com/jsp/jstl/sql</taglib-uri> 
          <taglib-location>/WEB-INF/sql.tld</taglib-location> 
        </taglib> 
      </jsp-config> 
    </web-app>

  • #2
    You need to access your pages through a controller, rather than directly. This will involve creating mappings for the urls in your *-servlet.xml file.

    Matt

    Comment


    • #3
      I have resolved it , thank you very much

      Comment


      • #4
        to mfc42d:
        I have the same trouble with you. how can I resolve ? thanks!

        Comment


        • #5
          access your jsp pages through a controller

          Comment

          Working...
          X