QueryString
<url>/people/search/email?filter={email}</url>
function main() { var filter = args["filter"]; }
Path parameter
<url>/person/{userName}</url>
function main() { // Get the user name of the person to get var userName = url.extension; }
Post Body
function main(){ //invalid input if(!json.has("users")){ status.setCode(status.STATUS_BAD_REQUEST, "The request body format is error."); return; } var usersIndex ; var users = json.get("users");//json array for (usersIndex = 0; usersIndex < users.length(); usersIndex++){ //Get user val var currentUser = users.get(usersIndex); }
其他補充
url
A host object providing access to the URL (or parts of the URL) that triggered the web script.
- context
- Alfresco context path, for example /alfresco
- serviceContext
- Alfresco service context path, for example /alfresco/service
- service
- Web script path, for example /alfresco/service/blog/search
- full
- Web script URL, for example /alfresco/service/blog/search?q=tutorial
- templateArgs
- a map of substituted token values (within the URI path) indexed by token name
- args
- Web script URL arguments, for example q=tutorial
- match
- The part of the web script URL that matched the web script URL template
- extension
- The part of the web script URL that extends beyond the match path (if there is no extension, an empty string is returned)
For example, imagine a web script URL template of
/user/{userid}
and a web script request URL of
/alfresco/service/user/fred?profile=full&format=html
The url root object will respond as follows:
- url.context => /alfresco
- url.serviceContext => /alfresco/service
- url.service => /alfresco/service/user/fred
- url.full => /alfresco/service/user/fred?profile=full&format=html
- url.args => profile=full&format=html
- url.templateArgs['userid'] => fred
- url.match => /user/
- url.extension => fred
http://wiki.alfresco.com/wiki/Web_Scripts_Examples#URL_Argument_Handling
沒有留言:
張貼留言
留個話吧:)