我正在编写一个 REST 组件,但是当我不想为参数传递参数时遇到了困难。我的代码和 URL(PATH 样式)如下所示。
组件定义:
<cfcomponent rest="true" restPath="SearchRestAPI">
<cffunction name="restaurantResults" access="remote" httpMethod="get"
output="false" returntype="Query" produces="application/json"
restPath="Search/{city : ([a-zA-Z])*}/{address}/{type}">
<cfargument name="city" default="" type="string" restargsource="path">
<cfargument name="address" default="" type="string" restargsource="path">
<cfargument name="type" default="" type="string" restargsource="path">
调用 URL/Path 以使用 REST 服务。请注意,我不想为类型参数发送任何值,因此路径末尾有双斜杠:
http://localhost:8502/backend/section/SearchResAPI/Search/Calcutta/Lindsay Street//
但这会引发“未找到”错误。任何建议将不胜感激。