Dealing with RPC when doing multiple GWT modules

旧城冷巷雨未停 提交于 2020-01-05 04:42:12

问题


I did some refactoring of my gwt application, and make it multiple modules (i.e. multiple *.gwt.xml and EntryPoint)

Everything seems to work fine, except for the RPC. Since I refactored the application, from a single mygwtapp.gwt.xml into multiple gwt.xml files:

main.gwt.xml
user.gwt.xml
login.gwt.xml 

and so on...

I had to change the servlet mapping URL-pattern from:

/mygwtapp/someRPC

into /main/someRPC to make sure that RPC's will work for the main module. It works for the main module but not for the other modules. As each module is excepting to have RPC call relative to its module name like /user/someRPC

What is the work-around for this kind of scenario?


回答1:


you have to options, either to use setServiceEntryPoint() and set the absolute path ("/main/someRpc") or use @RemoteServiceRelativePath but set the path to ("../main/someRpc") :)




回答2:


Put rpc code in a shared dir, refer to it via source directive in you module descriptor, then make multiple mappings to the same servlet in your ’web.xml`.

<servlet-mapping>
    <servlet-name>SomeServiceServlet</servlet-name>
    <url-pattern>/moduleOne/rpc/SomeService</url-pattern>
    <url-pattern>/moduleTwo/rpc/SomeService</url-pattern>
    <url-pattern>/moduleThree/rpc/SomeService</url-pattern>
</servlet-mapping>


来源:https://stackoverflow.com/questions/8834946/dealing-with-rpc-when-doing-multiple-gwt-modules

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!