【问题标题】:grails remoting plugin - always 404?grails 远程处理插件 - 总是 404?
【发布时间】:2011-04-08 21:34:36
【问题描述】:

我正在尝试向 Spring Web 应用程序公开远程接口,但我遇到了问题,总是得到 404。我下面的设置有什么问题?

Grails
服务 - 包 mypackage

class RemoteUserService implements RemoteUserServiceInterface {
    static expose = ['httpinvoker']

    User findUser(String userId) {
        return User.findByUserId(userId);
    }
}

src/groovy/mypackage

class RemoteUserService implements RemoteUserServiceInterface {
    static expose = ['httpinvoker']

    User findUser(String userId) {
        return User.findByUserId(userId);
    }
}

春天:
mypackage

public class MyController extends AbstractController {
    RemoteUserServiceInterface remoteUserService
}

appContext

<bean id="viewController" class="mypackage.MyController">
    <property name="remoteUserService" ref="remoteUserService"/>
</bean>

<bean id="remoteUserService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://localhost:8080/grails-app-name/httpinvoker/RemoteUserService"/>
    <property name="serviceInterface" value="mypackage.RemoteUserServiceInterface"/>
</bean>

【问题讨论】:

  • (1) 在您的问题描述中,我相信您在应该复制/粘贴界面代码的地方复制/粘贴了服务代码。 (2) 通过浏览器访问“localhost:8080/grails-app-name/httpinvoker/RemoteUserService”时是否出现 404 错误?或者这只是使用远程 MyController 连接时的问题?
  • 如果我直接在浏览器中访问,我会得到 404。该接口只定义了服务中可用的单个方法。

标签: spring grails groovy remoting httpinvoker


【解决方案1】:

你需要定义一个UrlMapping

"$controller/$action?/$id?" {}

否则插件将无法正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-29
    • 2013-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多