简体   繁体   中英

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?

This is intended as a simple web server and framework for students in a tutorial class.

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.

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.

It's also very lightweight and quite easy to pick up.

I'm very impressed with the Play! Framework which I think would meet most of your requirements in terms of MVC. It's a lot like Rails etc, and supports annotations-based Hibernate persistence out of the box. 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.

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.

If its for teaching MVC why don;t you explain them by using JSP and Servlet on Tomcat. 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.

你们怎么看待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. 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 . If you want to hide the IoC, that's pretty easy to do as well. 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 . My was able to write a simple webapp and get it up and running within (with some coaching of course). 能够写一个简单的网络应用程序,并在内启动并运行(当然还有一些指导)。 No joke !

Does anyone know of a simple Web MVC framework and Web Server for Java that is open source?

See HybridJava .

simple mvc

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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