What's the best Java web framework for my need

2019-03-12 15:47发布

I'm creating an web application for company intranet, because other parts of this system are written in Java, so for integration purposes Java was chosen as a web frontend.

There are the requirements:

  • it has to be simple to learn in short period of time
  • it has to support MVC pattern
  • no extended xml configuration
  • application will consist of many form that user will fill, and some js to help with it
  • good IDE plugins that will help with development

I was thinking of Wicket/Spring MVC/Stripes

What are your recommendations regarding those requirements? What other frameworks, that are probably better for my application should I look at?

Also: can you comment those three frameworks on how do they meet my requirements?

13条回答
叛逆
2楼-- · 2019-03-12 16:05

Have a look at the play framework and walk through the tutorial. I'm pretty sure that I will come back to this framework, when I have to/want to write a web application.

查看更多
何必那么认真
3楼-- · 2019-03-12 16:06

I've very successfully built a small internal company app. in Clojure using the Compojure framework. It's a very simple and elegant framework that should meet your needs if you're willing to learn Clojure.

Example code from the Compojure Wiki that implements a simple calculator:

(ns example 
  (:use compojure)) 

(defn html-doc 
  [title & body] 
  (html 
    (doctype :html4) 
    [:html 
      [:head 
        [:title title]] 
      [:body 
       [:div 
    [:h2 
     ;; Pass a map as the first argument to be set as attributes of the element
     [:a {:href "/"} "Home"]]]
        body]])) 


(def sum-form 
  (html-doc "Sum" 
    (form-to [:post "/"] 
      (text-field {:size 3} :x) 
      "+" 
      (text-field {:size 3} :y) 
      (submit-button "=")))) 

(defn result 
  [x y] 
  (let [x (Integer/parseInt x) 
        y (Integer/parseInt y)] 
    (html-doc "Result" 
      x " + " y " = " (+ x y)))) 

(defroutes webservice
  (GET "/" 
    sum-form) 
  (POST "/" 
    (result (params :x) (params :y)))) 

(run-server {:port 8080} 
  "/*" (servlet webservice))
查看更多
别忘想泡老子
4楼-- · 2019-03-12 16:07

I have built a number of web applications of varying size with Wicket.

Wicket takes a very different approach to things compared to most other web frameworks. If you have experience with building Java apps with Swing, building Wicket components will probably seem familiar to you. The main thing that drives my choice between Wicket and some other framework (Struts 2 tends to be the other one) is the "statefullness" of the web app. Wicket is great if the pages are stateful. If not, the value it adds, IMO, decreases significantly. One of my favorite parts in Wicket is the way it separates code from the markup, and how an .html file can extend another one. I have yet to really look into the best practices of making a web app built with Wicket very "ajaxy" - so far my experiences around integrating with JavaScript frameworks have been pretty clunky.

Whether or not Wicket is simple to learn in a short period of time is difficult to say without knowing more about your background. I also haven't used any IDE plugins, nor have I felt the need for such. The other items on your list - check!

查看更多
趁早两清
5楼-- · 2019-03-12 16:13

I can recommend Wicket. It is quite hard to learn, but then you'll love it. It's the first web framework I actually like to work with.

Note that Wicket is not good for quick and dirty solutions. Use it only if you like clean and ellegant solutions and you are ready to invest +10% of time for great code reusability, readability.

I mean, for example, there's no quick <% if( ... ){ %> ... <% }%> in Wicket.

Well... read some nice tutorial and you'll get my point. Here's my humble list of resources: http://ondra.zizka.cz/stranky/programovani/java/web/wicket/index.texy

查看更多
孤傲高冷的网名
6楼-- · 2019-03-12 16:14

I would use Wicket, which comes without XML config. It is clean and relatively easy to learn. Don't use Spring MVC if you aren't a big fan of XML. Spring can be configured with Java - in theory. But in practise you'll end up to configure it with verbose XML. Another shortcoming is Spring MVC is more flexible than it has to be, what means you have to learn more than you really need.

查看更多
成全新的幸福
7楼-- · 2019-03-12 16:22

Maybe Spring Roo? It works very well when you app mostly about forms and reports.

As alternative i can recommend you Grails, but there can be some complication when integrating it with your current java code.

查看更多
登录 后发表回答