我制作了最简单的Pedestal项目并在我的本地repl中运行它。但是,在localhost:8890
检查浏览器后,我看到 (替换字符)而不是实际文本(西里尔符号),我放入了我的基座路线。
我还检查了浏览器devtools响应标头: Content-Type:text / html; charset = utf-8 。
在你问之前:
charset=UTF-8
作为回应,您可以在下面的代码中看到。core.clj
文件也采用UTF-8编码。整个项目代码:
(ns samplepedestal.core
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :as route])
(:gen-class))
(defn html-response
[req]
{:status 200
:body "<html lang=\"ru\">
<head>
<meta charset=\"utf-8\" />
<title>Текст на русском</title>
</head>
<body>Текст на русском</body>
</html>"
:headers {"Content-Type" "text/html; charset=UTF-8"}})
(def routes
(route/expand-routes
[[["/" {:get `html-response}]]]))
(def service-map
{::http/routes routes
::http/type :jetty
::http/port 8890})
(defn start []
(http/start (http/create-server service-map)))
;; -- Interactive development
(defonce server (atom nil))
(defn start-dev []
(reset! server
(http/start (http/create-server
(assoc service-map
::http/join? false)))))
(defn stop-dev []
(http/stop @server))
(defn restart []
(stop-dev)
(start-dev))
;; ---
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
这是一种奇怪的行为,我不知道我缺少什么,所以任何帮助将不胜感激。谢谢!
答案 0 :(得分:2)
我认为问题在于REPL如何开始。你有什么东西沿着
启动nREPL服务器......“C:\ Program Files \ Java \ jdk1.8.0_66 \ jre \ bin \ java“ -Dfile.encoding = Cp1251 -XX:-OmitStackTraceInFastThrow -Dclojure.compile.path = D:\ workspace-clojure \ the-next-big-server-side-thing \ target \ classes -Dthe-next-big-server-side-thing.version = 0.0.1-SNAPSHOT -Dclojure.debug = false -Didea.launcher.port = 50071“-Didea.launcher.bin。
什么时候REPL开始?
如果是这样,您可能需要添加新的JVM参数来修复它。