GWT上传者 - 春季



在我的网络应用程序中,我正在使用GWT,我想使用GwtUploader。问题是我无法将任何服务@Autowire到我的类中来处理请求。可能因为它不是弹簧组件,但我不知道如何解决问题。

这是我的配置:

Servlet:

@Component("gwtUploadServlet")
public class GwtUploadServlet extends UploadAction {
private static final long serialVersionUID = 1L;
    @Autowired
    SomeService .....;
    public String executeAction(HttpServletRequest request,
        List<FileItem> sessionFiles) {
        .....
    }
}

网站.xml:

<servlet>
    <servlet-name>gwtUploadServlet</servlet-name>
    <servlet-class>xxx.gwtUploader.GwtUploadServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>gwtUploadServlet</servlet-name>
    <url-pattern>/bbsapp/fileUpload</url-pattern>
</servlet-mapping>

我在很多地方使用服务,它们工作正常。

我解决了添加问题:

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    // a workaround for forcing this servlet to autowire its components
    WebApplicationContext webAppCtx = WebApplicationContextUtils
            .getRequiredWebApplicationContext(getServletContext());
    webAppCtx.getAutowireCapableBeanFactory().autowireBean(this);
}

现在我有会话问题。当我尝试使用服务时,我得到:

Error creating bean with name 'scopedTarget.userSessionService': Scope 'session' 
is not active for the current thread; consider defining a scoped proxy for this 
bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: 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? If you are actually operating within a web 
request and still receive this message, your code is probably running outside 
of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener 
or RequestContextFilter to expose the current request.

相关内容

  • 没有找到相关文章

最新更新