0

1.通过在网上搜索,我了解到要将 spring 与 gwt 一起使用,我必须将默认 DispatcherServlet 替换为 org.spring4gwt.server.SpringGwtRemoteServiceServlet 。但是我看到的所有geomajas(使用spring + gwt)示例实际上都使用了应该被替换的DispatcherServlet。我怎么也能这样做?.

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
    <display-name>Geomajas application</display-name>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            <!-- framework context -->
            classpath:org/geomajas/spring/geomajasContext.xml

            <!-- use rasterizing -->
            classpath:org/geomajas/plugin/rasterizing/DefaultRasterizedPipelines.xml

            <!-- application context -->
            WEB-INF/applicationContext.xml
            WEB-INF/layerOsm.xml
            WEB-INF/mapOsm.xml
       </param-value>
    </context-param>

    <filter>
        <filter-name>CacheFilter</filter-name>
        <filter-class>org.geomajas.servlet.CacheFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>CacheFilter</filter-name>
        <url-pattern>*</url-pattern>
    </filter-mapping>

    <!-- only needed for direct GWT -->
    <listener>
        <listener-class>org.geomajas.servlet.PrepareScanningContextListener</listener-class>
    </listener>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:META-INF/geomajasWebContext.xml</param-value>
            <description>Spring Web-MVC specific (additional) context files.</description>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/d/*</url-pattern>
        <url-pattern>/${artifactId}/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

</web-app>
  1. 我必须对上述文件进行哪些修改才能添加另一个 spring 管理的 servlet?
4

1 回答 1

2

下面是我如何通过 |SpringGwtRemoteServiceServlet web.xml` 将 Spring 与 GWT 集成::
In

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<servlet>
<servlet-name>dispatch</servlet-name>
<servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>dispatch</servlet-name>
<url-pattern>/dispatch/*</url-pattern>
</servlet-mapping>



<servlet>
    <servlet-name>springGwtRemoteServiceServlet</servlet-name>
    <servlet-class>org.spring4gwt.server.SpringGwtRemoteServiceServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>springGwtRemoteServiceServlet</servlet-name>
    <url-pattern>/nameOfYourApp/springGwtServices/*</url-pattern>
</servlet-mapping>

然后,每当您希望定义 Spring 托管服务时,springGwtServices请在以下位置使用RemoteServiceRelativePath

import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.google.gwt.user.client.rpc.RemoteService;

@RemoteServiceRelativePath("springGwtServices/userService")
public interface UserService  extends RemoteService{

}

对于一个实现示例:

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

@Service("userService")
public class UserServiceImpl extends RemoteServiceServlet implements UserService{

}

我希望这是你需要的

于 2013-07-04T14:26:59.517 回答