简体   繁体   English

简单的Web服务器和Java的MVC框架

[英]Simple Web Server and MVC framework for Java

Does anyone know of a simple Web MVC framework and Web Server for Java that is open source? 有谁知道一个简单的Web MVC框架和Web Server for Java是开源的吗?

This is intended as a simple web server and framework for students in a tutorial class. 这是一个简单的Web服务器和框架,适用于教程类中的学生。

It's important these both the web server and MVC framework are simple, OSS so students can easily peer under the hood and the tutors can easily support it, learn it and teach it. 重要的是,这些Web服务器和MVC框架都很简单,OSS让学生可以轻松地了解并且导师可以轻松地支持,学习和教授它。

UPDATE The suggestion I can avoid the single jar issue by unpacking several jars and joining them into one is a good suggestion. 更新建议我可以通过打开几个罐子并将它们加入一个罐子来避免单罐问题,这是一个很好的建议。 I'll definitely take it, and thus relax the single jar requirements 我肯定会接受它,从而放松单罐要求

You could have a look at Stripes , which does not have any compile time dependencies (apart from itself, apparently) at all and only requires COS and Commons Logging during runtime. 您可以查看Stripes ,它根本没有任何编译时依赖性(显然除了它自己),并且在运行时只需要COSCommons Logging

It's also very lightweight and quite easy to pick up. 它也很轻巧,很容易拿起。

I'm very impressed with the Play! Play给我留下了非常深刻的印象 Framework which I think would meet most of your requirements in terms of MVC. 我认为框架可以满足您在MVC方面的大多数要求。 It's a lot like Rails etc, and supports annotations-based Hibernate persistence out of the box. 它与Rails等很相似,并支持开箱即用的基于注释的Hibernate持久性。 The only three 'odd' things worth mentioning are that it: 唯一值得一提的三个“奇怪”事情是它:

  1. I think it has its own built in implementation of properties (using reflection and byte code modifications) 我认为它有自己内置的属性实现(使用反射和字节码修改)
  2. It uses exceptions for flow control 它使用异常进行流量控制
  3. Its templating may be a little basic for some requirements, but on the whole it's fine for simpler stuff. 对于某些要求,它的模板可能有点基础,但总的来说它对于更简单的东西来说很好。

None of these is a showstopper in terms of producing a good website quickly, but points 1 and 2 may put you off if you are trying to teach Java at the same time. 在快速建立一个好的网站方面,这些都不是一个显而易见的问题,但如果你试图同时教授Java,第1点和第2点可能会让你失望。

If having a single jar is important to you, you can just unjar multiple jars and then recombine into one single jar (watching out for any duplicates or file clashes). 如果有一个罐子对你很重要,你可以解开多个罐子,然后重新组合成一个罐子(注意任何重复或文件冲突)。

That may be easier than compromising your MVC choice for the single-jar requirement. 这可能比为单罐需求而牺牲MVC选择更容易。

If its for teaching MVC why don;t you explain them by using JSP and Servlet on Tomcat. 如果它用于教授MVC为什么不通过在Tomcat上使用JSP和Servlet来解释它们。 If you want to teach using some framework then in my opinion JSF on tomcat is the easiest as not much configuration required and the backend code is also only plain Java and no framework specific API. 如果你想使用一些框架进行教学,那么在我看来,tomcat上的JSF是最简单的,因为需要的配置并不多,后端代码也只是普通的Java而且没有特定于框架的API。

你们怎么看待Wicket

If you're teaching someone about fixing cars, you could certainly start with a Briggs & Stratton lawn mower engine and work your way up. 如果您正在教某人修理汽车,您当然可以从Briggs&Stratton割草机引擎开始,然后继续前进。 I'd suggest starting them with something that's immensely popular instead--a Honda Civic, in our metaphor. 我建议用一些非常受欢迎的东西来开始它们 - 在我们的比喻中,本田思域。

Starting with an immensely popular framework will yield better Internet resources and will have the benefit of lots of others who had run into the same problems before. 从一个非常受欢迎的框架开始,将产生更好的互联网资源,并且会受益于之前遇到过相同问题的许多其他人。 Also, using something used in the real world and which would appear in job postings isn't a bad way to create productive members of the development community. 此外,使用现实世界中使用的内容以及在职位发布中出现的内容并不是创建开发社区的高效成员的坏方法。

I'd suggest Spring MVC . 我建议使用Spring MVC If you want to hide the IoC, that's pretty easy to do as well. 如果你想隐藏IoC,这也很容易。 A sample: 一个样品:

package samples;

public class SampleController extends AbstractController {

    public ModelAndView handleRequestInternal(
        HttpServletRequest request,
        HttpServletResponse response) throws Exception {

        ModelAndView mav = new ModelAndView("hello");
        mav.addObject("message", "Hello World!");
        return mav;        
    }
}

Try the ultra simple java based web MVC framework VRaptor 2 . 尝试超简单的基于Java的Web MVC框架VRaptor 2 My 5 year old niece was able to write a simple webapp and get it up and running within 7 minutes (with some coaching of course). 5岁的侄女能够写一个简单的网络应用程序,并在7分钟内启动并运行(当然还有一些指导)。 No joke ! 可不是闹着玩的 !

Does anyone know of a simple Web MVC framework and Web Server for Java that is open source? 有谁知道一个简单的Web MVC框架和Web Server for Java是开源的吗?

See HybridJava . HybridJava

simple mvc 简单的mvc

 package app.controllers;
    import mvc.*;
    class mycontroller implements Controller {
        public View Controller() {
            return new View("myview");
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM