1

I am going to develope a web application. Which framework(struts1 or struts2) should i choose? Which one is easier to understand and code. Is applying CSS/HTML in struts2 difficult?

ankit
  • 363
  • 2
  • 7
  • 16
  • 1
    struts2 is very different, but mostly superior to struts1. Can you explain why you are choosing between only those two options? Are there other requireements? – Anders Forsgren Apr 12 '12 at 12:30
  • actually i wrote 1 small web-application using struts2 but applying css was very difficult – ankit Apr 12 '12 at 12:38
  • @ankit How was it difficult? That makes no sense. That aside, the idea of choosing Struts 1 for new development is a *horrible* idea, I can't even imagine why it would be a realistic option any longer. – Dave Newton Apr 12 '12 at 13:06

4 Answers4

2

[I deleted the part about this being a too generic question, as I misread the initial question, sorry...] Use struts2 since they obviously learned from what was flawed in Struts1. They introduced interfaces so that you can extend your own classes and use Dynaforms for form data binding (in struts 1 you have to write such a FormBean for every f*** form in your app). If you use struts you should also use tiles.

Another framework that is definitely worth a look is Wicket. So far so good. Good luck!

bennidi
  • 2,092
  • 21
  • 27
  • True, I did get the question wrong (I somehow ignored that it was only between struts 1 and struts 2). I think the choice between struts 1 and two is quite obvious. And from the question I derived that further advise to different frameworks would be helpful. Also, the question was not limited to action based frameworks and IMHO there are far better frameworks available than struts. – bennidi Apr 14 '12 at 13:02
2

I have used Struts1 and Struts 2 extensively. Struts2 is far better than Struts 1. Struts 2 is the way forward. There are a whole lots of improvements in Struts 2.

  1. The use of interceptors.
  2. Pojo like actions
  3. No action forms.
  4. Easy integration with other frameworks like spring, dwt etc
Umesh Awasthi
  • 23,407
  • 37
  • 132
  • 204
Uchenna Nwanyanwu
  • 3,174
  • 3
  • 35
  • 59
  • Dear Uchenna how to apply good lookin css/templates in struts2 application. – ankit Apr 12 '12 at 12:46
  • If the View technology you are using is jsp, applying css is straightforward. Every struts 2 tag has these attributes cssClass and cssStyle. With the cssClass, you can enter the css class name from your css template. With the cssStyle you can directly enter the css styling on the tag. but before you use the tag you need to reference struts 2 tag in your page using this <%@ taglib prefix="s" uri="/struts-tags" %>. For a text field you can then do this: . – Uchenna Nwanyanwu Apr 12 '12 at 12:59
  • Thnx Uchenna but i am facing difficulty in applying css.for example if i want to display a error message corresponding to text field. it is getting displayed at different coordinates for differnet browser – ankit Apr 12 '12 at 13:05
  • Are you using struts 2 tag libraries? Can you post your code so that i can look at it. Just the lines that are not working fine. – Uchenna Nwanyanwu Apr 12 '12 at 13:07
  • @ankit If you're having an issue with S2 and CSS please open a new question. What you're describing makes no sense so far. – Dave Newton Apr 12 '12 at 13:08
  • 1
    @ankit: just to add what Dave has already said, use simple theme in S2 and you are free to use any css in any way you want. – Umesh Awasthi Apr 12 '12 at 14:43
  • @Uchenna:Just want to correct you.There is no way to compare Strus2 and Struts2, and Struts2 is not lot of improvement, its something different than Struts1, unfortunately for many it seems like they think Struts2 is enhance version of Struts2 which is not a case at all :) – Umesh Awasthi Apr 12 '12 at 18:19
  • @see this question and answer: http://stackoverflow.com/questions/4561179/how-to-disable-struts-2-table-generation-for-form if you want to go a bit further there are other template solutions I promote apache tiles, but sitemesh is another alternative (the two can be complimentary). – Quaternion Apr 12 '12 at 18:24
0

I think struts2 is better .Please read the below article http://www.java-samples.com/showtutorial.php?tutorialid=200

ohm
  • 140
  • 1
  • 5
0

Use struts 2 and you can also integrate it with spring.

code_fish
  • 3,381
  • 5
  • 47
  • 90