Spring:从jsp访问scoped bean时出错

时间:2012-08-09 13:40:12

标签: spring spring-mvc scope session-variables sitemesh

我学会了如何从jsp访问会话范围的sping bean但是出现了以下错误:

No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? scoped beans from jsp

request.getSession().getAttribute("scopedTarget.otmSessionHolder")).getUserVO()

我的web.xml:

 <listener>
            <description>Spring Context Listener</description>
            <display-name>Spring Context Listener</display-name>
            <listener-class>
                org.springframework.web.context.ContextLoaderListener
            </listener-class>
        </listener>

        <listener>
            <display-name>Request Context Listener</display-name>
            <listener-class>
                org.springframework.web.context.request.RequestContextListener
            </listener-class>
        </listener>

        <servlet>
            <description>This Servlet intercepts all requests for this WebApplication</description>
            <servlet-name>SpringDispatcher</servlet-name>
            <servlet-class>
                org.springframework.web.servlet.DispatcherServlet
            </servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/beans/web/**/*-Beans.xml</param-value>
            </init-param>

<servlet>
        <description>This Servlet intercepts all requests for this WebApplication</description>
        <servlet-name>SpringDispatcher</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/beans/web/**/*-Beans.xml</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>

<servlet>
        <description>This Servlet intercepts all RESTful requests for this Web Application</description>
        <servlet-name>RESTfulSpringDispatcher</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/beans/web/RESTful-Beans.xml</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>

但我仍然得到这个例外 我使用sitemesh decorator作为模板。已经通过这些论坛,但无济于事。亲切地帮助我

0 个答案:

没有答案