Personal bias against Java's three-frame combination of SSH

Source: Internet
Author: User

The javaweb of most people is learning ssh:struts+spring+hibernate; I studied ten years ago (2006), when the fire was struts1.x, Struts2 was not born. These three frame combinations, I used for about 5 years time. In retrospect, it was painful to use these three frameworks to do the project, but there was no other option at the time, and there was no other choice but the MVC framework, compared to pure servlets and JSPs, the pain is mainly derived from control layers, views, and data queries. 3 years ago I no longer use struts and hibernate framework, there are many functions not to use, because are only small projects, data table basic not over 200. Struts JSP tags really do not use, including other JSP tags, MVC framework to the Request,session,response validator, the encapsulation and abstraction of the Interceptor will let the novice developers in the inside, it is recommended that beginners learn the servlet through SSH, Otherwise you will not see the nature of technology. Struts is just a shell of a servlet, a piece of clothing; you talk about an object, you don't want to study how her clothes are done, right? Hibernate automatically generated beans, so that the novice before the light, the original database operation is so simple, so convenient. Seemingly convenient is restricting, get a record really need to put all the fields are proposed? What if I looked up a field from another table? is HQL compatible with multiple databases useful? Brute Force Oo is trapped in hql, complicated by simple problems, like farming with handcuffs, all kinds of not free. Spring is what I have always admired. Its object management, IOC, configuration management, transactions, scheduling is really very practical, so far any of my projects have spring figure. In fact, I want to say is, sesame big small project you divide so many layers have bird use? To achieve a function to build a view, action, service, DAO, really in strict sense of layering it? I have seen a telecommunications outsourcing project in the addition of a simple query, need to create 9 classes or configuration files, the project can only be described by a random word, a group of people around the project nonsense, in fact, no one has mastered, difficult. By now I have become a write JSP, I am divided into view and handler. Data interaction Multi-use AJAX, data format is JSON handler.jsp
String cmd=request.getparameter ("C"); ApplicationContext spring = Webapplicationcontextutils.getrequiredwebapplicationcontext (Request.getSession (). Getservletcontext ()); JdbcTemplate Jdbc=spring.getbean ("JdbcTemplate", Jdbctemplate.class); UserBean userbean= (UserBean) Session.getattribute (Constants.session_user); Map<string,object> ret=new hashmap<string,object> (); Ret.put ("Success", true); Ret.put ("Code", 1); Ret.put ("message", "Operation succeeded"); Java.text.SimpleDateFormat sdf=new Java.text.SimpleDateFormat ("yyyymm"); if ("Getjoblist ". Equals (cmd)) {list<map<string,object>> list=jdbc.queryforlist (SQL); for (map<string,object> Map : list) {String c=colors[random.nextint (colors.length)];map.put ("BorderColor", c); Map.put ("bgcolor", c);} Out.println (json.tojsonstring (list));} else if ("drop". Equals (cmd)) {String id=request.getparameter ("id"); String stime=request.getparameter ("stime"); String etime=request.getparameter ("ETime"); Jdbc.update ("Update toa_onduty set stime=?,etime=?") Where id=? ", StimE,etime,id); Out.println (json.tojsonstring (ret));} else if ("editable". Equals (cmd)) {String stime=request.getparameter ("stime"); String etime=request.getparameter ("ETime");//ret.put ("Editable", Gridservice.iseditable (Userbean.getid (), Stime, etime)); Out.println (json.tojsonstring (ret));} Else{system.out.println ("The value of parameter C [" +cmd+ "] is wrong, system/workflow/manager/handler.jsp"); Out.println (Json.tojsonstring ( ret));}


functionReload (id,type) {cache={Id:id,type:type}; $("#calendar"). Fullcalendar (' removeevents '); $.post (handlerjsp,{c:"Getjoblist", Id:id,type:type},function(data) {if(data.length==0) {lgxinfo ("No scheduling Data");}Else{alert ("Have" +data.length+ "schedule Record"); }           for(vari=0;i<data.length;i++) {              varobj =NewObject ();[i].id; Obj.title=Data[i].title; Obj.start=parsedate (data[i].stime); Obj.end=parsedate (data[i].etime); //obj.description = data[i].description;Obj.backgroundcolor=Data[i].bgcolor; Obj.bordercolor=Data[i].bordercolor; Obj.allday=false;//if (data[i].allday==1) {//Obj.allday =true;//}else{//Obj.allday =false;//               }$ ("#calendar"). Fullcalendar (' renderevent ', obj,true); }      },"JSON");}

In general, I still use the platform to develop, with the platform to control the overall, only in the local function to adopt such a way of writing. Complex business logic I will also write a service for interface programming, let Spring unified management;

In this way, the general small operation, such as flowing, simple and fast.

Personal bias against Java's three-frame combination of SSH

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.