Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns fy_hrp275.core
- (:use compojure.core)
- (:use ring.util.response)
- (:use ring.middleware.reload)
- (:use ring.middleware.stacktrace)
- (:use ring.middleware.file)
- (:use ring.middleware.file-info)
- (:use hiccup.core)
- (:use hiccup.page-helpers)
- (:use clojure.contrib.sql)
- (:use fy_hrp275.middleware))
- (def *db*
- {:classname "net.sourceforge.jtds.jdbc.Driver"
- :subprotocol "jtds"
- :subname "sqlserver://10.0.1.12/hrp275;user=sa;password=rxmx1199"})
- (defn view-layout [& content]
- (html
- (doctype :xhtml-strict)
- (xhtml-tag "en"
- [:head
- [:meta {:http-equiv "Content-Type"
- :content "text/html; charset=utf8"}]
- [:title "Test"]
- [:link {:href "/test.css" :rel "stylesheet" :type "text/css"}]]
- [:body content])))
- (defn tag_h [tag]
- (str "<" tag ">"))
- (defn tag_t [tag]
- (str "</" tag ">"))
- (defn view-test []
- (view-layout
- ;; (with-connection *db*
- ;; (with-query-results rs ["select top 10 * from gy_ksdm"]
- ;; (let [ta1 (tag_h "table") ta2 (tag_t "table")
- ;; th1 (tag_h "th") th2 (tag_t "th")
- ;; td1 (tag_h "td") td2 (tag_t "td")
- ;; tr1 (tag_h "tr") tr2 (tag_t "tr")]
- ;; (doall (map (fn [x]
- ;; (str tr1
- ;; (str td1 (:ksdm x) td2)
- ;; (str td1 (:ksmc x) td2) tr2)
- ;; ) rs)))))))
- "你好"))
- (defroutes handler
- (GET "/test" []
- (view-test))
- (GET "/t1" []
- (java.io.ByteArrayInputStream. (.getBytes "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head><body>刘孟江</body></html>" "UTF-8")))
- (GET "/t2" []
- (java.io.ByteArrayInputStream. (.getBytes "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head><body>刘孟江</body></html>" "UTF-8"))
- ))
- (wrap! handler (:charset "utf-8"))
- (def app
- (-> #'handler
- ;;(wrap-file "public")
- ;;(wrap-file-info)
- (wrap-request-logging)
- (wrap-reload '[fy_hrp275.middleware fy_hrp275.core])
- (wrap-bounce-favicon)
- (wrap-stacktrace)))
Add Comment
Please, Sign In to add comment