Clojure Web应用程序 - 我从哪里开始? [英] Clojure web application - where do I start?

查看:99
本文介绍了Clojure Web应用程序 - 我从哪里开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我一直在研究Clojure,我喜欢这种语言。我想看看是否可以做一个小的Web应用程序,只是为了挑战自己。但是,我完全没有设置任何与Java相关的Web应用程序的经验。事实上,我真的没有太多的Java的经验。我从哪里开始?我有很多Apache和LAMP堆栈的经验,我知道在Apache我只是在大多数情况下使用Fast-CGI,但我不知道在Java世界(如果有一个)等价。

So lately I've been looking into Clojure, and I love the language. I would like to see if I can make a small web application in it, just to challenge myself. However, I have absolutely no experience setting up any Java-related web applications. In fact, I don't really have much experience with Java at all. Where do I start? I have lots of experience with Apache and the LAMP stack, and I know on Apache I would just use Fast-CGI in most cases, but I don't know the equivalent in the Java world (if there is one).

基本上,我只需要帮助设置服务器和启动它。我理解(有些)如何部署纯Java应用程序,但是纯Clojure应用程序呢?如何工作?我想,来自一个世界,所有的网络应用程序都是用脚本语言编写的,这对我来说是全新的。

Basically, I just need help with setting up the server and getting it started. I understand (somewhat) how to deploy a pure Java application, but what about a pure Clojure application? How does that work? I guess, coming from a world where all web applications are written in scripting languages, this is all new to me.

哦,顺便说一下, I不想使用Clojure框架,例如Compojure。

Oh, and by the way, I don't want to use a Clojure framework such as Compojure. That would defeat the learning part of this.

推荐答案

我建议你从学习Servlet-API开始,它支持所有与Java世界中的HTTP请求和响应相关的东西。 HttpServletRequest HttpServletResponse 在这里覆盖了很多地方。 Jetty是一个不错的选择;有关Clojure和Jetty的一个很好的介绍,请访问 http:// robert.zubek.net/blog/2008/04/26/clojure-web-server/ (使用Jetty 6)。

I'd recommend you start by learning the Servlet-API, which backs all things related to HTTP-requests and responses in the Java world. HttpServletRequest and HttpServletResponse cover a lot of ground here. Jetty is a nice choice here; there's a good introduction about Clojure and Jetty at http://robert.zubek.net/blog/2008/04/26/clojure-web-server/ (using Jetty 6).

话虽如此,Compojure基本模型也是相当低级的:它只是在Clojure-datastructures中包装请求和响应,但是你仍然负责所有路由,生成正确的响应代码。生成 ETag 等,这有时是比LAMP堆栈更低级的东西。

That being said, Compojure's basic model is pretty low-level too: it just wraps the requests and responses in Clojure-datastructures, but you are still responsible for all routing, generating the right response codes. generating an ETag etc., which is sometimes more low-level stuff than with a LAMP-stack.

这篇关于Clojure Web应用程序 - 我从哪里开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆