5
有沒有辦法讓戒指處理程序中的HttpServletRequest對象? 我使用Noir開發Web應用程序。處理URI時,我需要獲取HttpServletRequest obj。所以我使用(noir.request.ring-request)函數取回包含以下內容的ring請求映射:servlet-request key,但值爲nil。這是做這件事的正確方法還是我錯過了什麼?如何在環處理程序中獲取HttpServletRequest?
以下是代碼:
(ns my-app
(:use noir.request))
(defpage [:get "/app"] []
(str (ring-request)))
結果:
{:remote-addr "127.0.0.1", :scheme :http, :query-params {}, :session {}, :form-params {}, :multipart-params {}, :servlet #, :request-method :get, :query-string nil, :content-type nil, :cookies {"ring-session" {:value "eb509a65-d33a-40d2-9646-e2ff785428b0"}}, :uri "/app", :server-name "127.0.0.1", :params {}, :headers {"cookie" "ring-session=eb509a65-d33a-40d2-9646-e2ff785428b0", "accept-charset" "GBK,utf-8;q=0.7,*;q=0.3", "accept-language" "en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4", "accept-encoding" "gzip,deflate,sdch", "accept" "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "user-agent" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2", "connection" "keep-alive", "host" "127.0.0.1:8080"}, :servlet-request #, :content-length nil, :server-port 8080, :character-encoding nil, :servlet-response #, :body #, :servlet-context #}
出於興趣,什麼是你想做的請求對象?也許還有其他方法可以實現這一點。 –