Anatomy of G-WAN URI servlets

大憨熊 提交于 2020-02-07 08:26:07

问题


gwan/csp/strangesubfolder/inc.c can be visited via http://domainName.com/strangesubfolder/?inc

I feel this servlet mapping strange but that suits my need. I can't find the mapping description in the gwan user's manual.

Please correct me if I am wrong and confirm if it is the expected behavior.


回答1:


Yes it is a standard feature.

The '?' tells G-WAN that it is a servlet. If there's no '?' it will look for the file in WWW folder.

Update:

Now I understand your confusion.

Since version release 3.3.27 this has been changed so users can easily make restful URL's

G-WAN timeline

Read the update for March 27 2012.

Now you need to place the '?' before the actual servlet name. By doing this G-WAN can efficiently rewrite '/' to '&' so you can use restful URL's like these without writing any code.

//Old way
http://domain/?user/profile&user1
http://domain/?blog/archive&2012&march

//New way (more restful no '&')
http://domain/user/?profile/user1
http://domain/blog/?archive/2012/march



回答2:


Yes, as Richard rightly (and promptly, thanks Richard!) explained it, this is the expected behavior.

The directory /gwan/.../csp/script.c is used to store servlets that must be run while /gwan/.../www/script.c is used to store files intended to be served as an HTTP resource.

The corresponding URLs are GET /?script.c and GET /script.c.

Any sub-directory used in the /csp or /www folders is reflected accordingly in the HTTP request: GET /folder/?script.c for dynamic contents and GET /folder/script.c for static contents.

The choice of moving the '?' query character (which can be replaced by other characters) from the old GET /csp?/folder/script.c form to the new GET /folder/?script.c form was motivated by the need to:

  • distinguish servlet names from folder names (requests can lack the servlet extension for the defined 'default' programming language, which is C if nothing is defined)
  • allow any number of sub-directories in HTTP requests
  • allow any number of query arguments in HTTP queries
  • distinguish between folders and query arguments in HTTP requests
  • make it possible to have RESTFUL requests in all the above cases.

It took us a while to find the proper mix of features with the minimal verbosity but experience has shown that this works well.

Here is an example of a RESTFUL query having both a sub-folder and query arguments:

GET /folder/?script/arg1/value1/arg2/value2/arg3/value3

By default, this is a C script, unless another language (among the 15 available for scripting) has been defined as the 'default' language.

Note that the 50+ script examples provided in the download archive illustrate this scheme which is also presented on the developers page.



来源:https://stackoverflow.com/questions/13396510/anatomy-of-g-wan-uri-servlets

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