尝试对特殊的oracle pl / sql验证程序包进行自定义调用,该程序包执行除自定义域级验证程序之外的操作,但不会触发" firemyvalidations"。你可以看到我试过的一些被注释掉的东西。谁能发现我的问题?我使用grails 3.2.6 with angularjs rest profile。
urlmappings.groovy
package fytrnlt
class UrlMappings {
static mappings = {
delete "/$controller/$id(.$format)?"(action:"delete")
get "/$controller(.$format)?"(action:"index")
get "/$controller/$id(.$format)?"(action:"show")
post "/$controller(.$format)?"(action:"save")
put "/$controller/$id(.$format)?"(action:"update")
patch "/$controller/$id(.$format)?"(action:"patch")
//"/fetchStvnatnData"(controller: 'FybkbraController', action: 'fetchStvnatn')
"/events"(resources:"event")
"/fytrnlts"(resources:"fytrnlt")
//"/fytrnlts"(resources:"fytrnlt"){"/fytrnlts/myvalidations" (controller: "FytrnltController", action: "myvalidations", method: "POST")}
// "/fytrnlts/myvalidations" (controller: 'FytrnltController', action: 'myvalidations', method: 'POST')
"/firemyvalidations" (controller: 'FytrnltController', action: 'myvalidations', method: 'GET')
"/spridens"(resources:"spriden")
// "/fybkbras"(resources:"fybkbra")
"/fybkbras"(resources:"fybkbra"){"/fetchStvnatnData" (controller: "FybkbraController", action: "fetchStvnatn", method: "GET")}
"/fytbanks"(resources:"fytbank")
"/fyrsigns"(resources:"fyrsign")
"/"(view: '/index')
"500"(view: '/error')
"404"(view: '/notFound')
}
}
FytrnltController.groovy
package fytrnlt
import grails.rest.*
import grails.converters.*
import fytrnlt.BannerService
class FytrnltController extends RestfulController {
//def bannerService
static responseFormats = ['json', 'xml']
FytrnltController() {
super(Fytrnlt)
}
def myvalidations(){
//def String mresult = bannerService.dataValidation()
def fytrnlt = Fytrnlt.get(4)
def CheckResult = fytrnlt.bannerService.documentValidation(fytrnlt.checkpayeepidm, fytrnlt.benefiaryname, fytrnlt.id, fytrnlt.userid, 1, fytrnlt.version, fytrnlt.actnum, fytrnlt.actnumintmdry, fytrnlt.swift, fytrnlt.createdate, null)
respond CheckResult, [excludes: ['class']]
/*
def fytrnlt = Fytrnlt.get(params.id)
if (fytrnlt.validate()) {
def CheckResult = fytrnlt.bannerService.documentValidation(fytrnlt.checkpayeepidm, fytrnlt.benefiaryname, fytrnlt.id, fytrnlt.userid, 1, fytrnlt.version, fytrnlt.actnum, fytrnlt.actnumintmdry, fytrnlt.swift, fytrnlt.createdate, null)
return CheckResult
} */
}
}
通过Postman命中端点会返回404错误。
Grails生成以下内容:
WARN --- [nio-8080-exec-2] o.s.web.servlet.PageNotFound : No mapping found for HTTP request with URI [/firemyvalidations] in DispatcherServlet with name 'grailsDispatcherServlet'
答案 0 :(得分:0)
您无需将Controller后缀添加到URL Mapping:
因此,您可以替换:
"/firemyvalidations" (controller: 'FytrnltController', action: 'myvalidations', method: 'GET')
使用:
"/firemyvalidations" (controller: 'fytrnlt', action: 'myvalidations', method: 'GET')