SPRINGMVC + Oracle Stored procedures build high-performance, flexible and maintainable Java Web architecture

Source: Internet
Author: User
Tags blank page java web

MVC makes simple business more complicated.

I do not know if you are using the MVC pattern to develop the project when you feel very troublesome, a simple delete and change the action is involved in a number of file operations.

Take a data increase as an example.

Let's say we use hibernate and the DAO layer is already encapsulated

It can be seen that if we write an add function in the system need to write their own place at least JSP, action, Service,servicesimpl four layer.

If it is a complex add operation then we will probably also define the DAO layer of the interface and method, that is, 6-layer operation.

If you use MyBatis to write at least 4 layers, the common case is to write 6 layers, because we need to write some SQL statements ourselves,

This is going to write mapper.xml and Mapper.java so because it's 6 layers.

A simple action to write 4 or 6 layers I always feel that it is such a troublesome thing, and easy to make mistakes.

If one day this new action needs to add a field, then put in whose current is an egg ache action, add a field enough to make you disgusting half a day.

Let's see how many places to change.

1. Database

2, Pojo

3. DAO configuration file

4. Interface

You may also want to modify the action and other places. And the configuration file is very easy to appear bug ...

Anyway, I've had enough of this kind of day.

Two-tier streamlined architecture

Later into Hunan than the United technology after the company framework inspired by the transformation of a 2-tier architecture that uses SPRINGMVC and Oracle stored procedures to implement the Web architecture, the Gospel to

Let's look at a simplified flowchart.

We implement all of the business logic through the Oracle process, and then just call the JavaScript library that we have written on the page to get the results of the process directly.

So most of the business we have as long as 2 processing 2 places on it, first write the process in the write interface call. Isn't it convenient? And the process of processing data is much faster than MVC.

As for the interface display aspect, the HTML interface reads much faster than the JSP page, so the performance aspect is a great improvement.

And we don't have a pojo here. So if you change the field, you don't need to change anything, change the stored procedure and the page. The workload is a bit less than in MVC. That means the productivity is twice times better.

The principle is shown on the diagram below in code to illustrate (with a functional management as an example):

Database tables
--Create tablecreate table Ex_sys_power (  ID            INTEGER not NULL,  Icon_path     VARCHAR2 (),  FUNCTION _path VARCHAR2 (+),  MARK          VARCHAR2 (4000),  State         Integer,  GRADE         integer,  parent_ ID     Integer,  yxbz          Integer,  NAME          VARCHAR2 (500))

  

Stored Procedures

CREATE OR REPLACE Package BODY a_es_power is    --============= query  PROCEDURE Find_power_byid by ID (p_id     INTEGER ,                            P_result out plat_constant. RESULTSET) is the  BEGIN    OPEN p_result for      SELECT * from        ex_sys_power       WHERE ID = p_id and         yxbz = 1;
   end; END;

  

HTML interface
<! DOCTYPE html>

Ajaxprox.js

/** * Author: Kang Youyao */function Getrootpath () {var Curwwwpath = Window.document.location.href;var PathName = window.document. Location.pathname;return curwwwpath.substring (0, Curwwwpath.indexof (pathname)) + pathname.substring (0, PATHNAME.SUBSTR (1). IndexOf ('/') + 1);} var basepath = Getrootpath ();d ocument.write (' <script type= ' text/javascript "src=" ' + basepath+ '/public/hui/lib/ Layer/1.9.3/layer.js "></script>"), function Ajaxproxy (async) {if (async! = null) {This.async = async;} else {thi S.async = true;} This.gs_parameter = {};this. state_success = ' 1 '; State_err = ' 0 '; this.result = null;} AjaxProxy.prototype.invoke = function (procedure, callback) {var url = basepath + "/center.do?p_id=" + Procedure;var $this  = this;layer.msg (' loading ', {icon:16}); if (This.async) {//Async $.ajax ({type: "Post", Url:url,data:this.gs_parameter,async: True,success:function (callbackdata) {var result = eval (callbackdata); if (result.requeststatus = = 0) {layer.closeall (' d Ialog '); Layer.msg (result.errmsg{icon:2}); return;} else {$this. result = Result;layer.closeall (' dialog '); callback ();}});} else {//sync $.ajax ({type: "Post", Url:url,data:this.gs_parameter,async:false,success:function (callbackdata) {var result = eval (callbackdata), if (Result.requeststatus = = 0) {layer.closeall (' dialog '); layer.msg (result.errmsg, {Icon:2 }); return;} else {$this. result = Result;layer.closeall (' dialog '); callback ();}});}}; AjaxProxy.prototype.addParm = function (index, value) {if (value = null) {value + = ""; value = encodeURIComponent (value); th is.gs_parameter["PARAM_" + index] = value;}}; AjaxProxy.prototype.getRowCount = function (mapName) {return eval ("This.result." + MapName + "[' Row_count ']");}; AjaxProxy.prototype.getValue = function (key) {return eval ("This.result." + key);}; AjaxProxy.prototype.getString = function (mapName, index, key) {return eval ("This.result." + MapName + ". row_value[" + Inde x + "['" + key+ "]");};

This is the front desk processing part of the back part of the direct to my Baidu cloud download it

Link: Http://pan.baidu.com/s/1eQuHwBK Password: JMPK

There are comments in the program you can refer to the reference, there is a bug where you can tell me ah, I am improving the improvement.

  

SPRINGMVC + Oracle Stored procedures build high-performance, flexible and maintainable Java Web architecture

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: info-contact@alibabacloud.com 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.