开发者

Is there a good Java back end platform/library/framework that keeps back and front ends loosely coupled?

Recent asp.net MVC experience has drastically reduced my .NET hate f开发者_如何学Pythonrom the front-end/UI dev perspective. Is there anything similar in Java or does that servlet/portlet business which I only vaguely understand as doing something other than CGI for some sort of multitasking performance benefit always require tight-coupling to the HTML?

If not, what would I need to read up on to help write something in Java that makes this possible? Is some popular library the culprit?

Also, if these mysterious n-lets improve performance why do so many Java sites seem slower on load-time to me?


Struts, Java Server Facelets, more than I want to list out MVC, MVVM, and any other pattern that's hot at the moment usually has a Java version floating around somewhere with some degree of usefulness or utility (some good some bad as in every other part of the world).

Read up on Patterns and basic computer science. Maybe go the read a shit ton of RFCs route as its the road less traveled and will give you information beyond your wildest dreams and make you seem incredible to regular programmers. After doing this implementing decoupled systems such as MVC pattern will seem like simple work.

Many java sites seem slower on load time because of a variety of reasons revolving around 1) poorly administered 2) poorly coded 3) JSP compile time on first access (ie read up on how JSPs work).

Anyways, I hope this answer helps.


I'm not sure what you mean by "tight coupling" with the front end.

Servlets need not always demand that they know about the client that's calling them. But they have to agree on something to be sent back and forth. One way to completely decouple the two is to use an agreed-upon wire protocol, be it REST-based HTTP or XML or - horrors - SOAP. Messages are exchanged, but the details of production and consumption are hidden from each other.

If you use Spring, which I heartily endorse, you need not be locked into JSPs. Spring web services and Velocity generated views are other alternatives.


Have a look at JSF 2.0, maybe in conjunction with Spring.

On the other hand, have a look at Spring MVC (3.0), it does not support the component style like JSF (and i think .asp) but it is a very good MVC framwork.


The framework I use a lot of the time is Spring MVC. It does a reasonable job of letting you keep your view (JSPs) separate from business logic.

EDIT: JSP alone is not sufficient. It is possible to put all your logic into a single JSP - it is possible to create a new database connection, fetch some rows, do some logic, and then display them. This is a very bad idea. By using Spring MVC (or another MVC framework - there are probably others out there), you separate the business logic (model), how things look to the user (view) and the logic for fetching data and wiring everything together (controller).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜