Here the main write action and service.
Write Service layer First:
The schema is as follows:
Public Interface UserService { public list<sysusercustom> findsysusercustom (Sysuserqueryvo Sysuserqueryvo)throws Exception; }
The project structure has been integrated in the previous building of the system.
Here's a little bit of ink to talk about the process:
Enter the address in the URL, and then enter the appropriate action according to the SPRINGMVC configuration. Execute the function inside and query the database to return the data to the page.
Here is the SPRINGMVC scan function registered with the bean.
As follows:
will automatically register the Yycg.**.action package with the @controller in the Bean container.
As follows:
Packageyycg.base.action;Importjava.util.List;Importorg.springframework.beans.factory.annotation.Autowired;ImportOrg.springframework.stereotype.Controller;ImportOrg.springframework.ui.Model;Importorg.springframework.web.bind.annotation.RequestMapping;ImportOrg.springframework.web.bind.annotation.ResponseBody;ImportYycg.base.pojo.vo.SysuserCustom;ImportYycg.base.pojo.vo.SysuserQueryVo;ImportYycg.base.process.result.DataGridResultInfo;ImportYycg.base.service.UserService;/** Users click on a link on the page to come here, and then execute the method here, from the database to find the data I want to return to the *model, and then the model inside the data will be passed to the displayed page, when the page to display, the model inside the data display * to complete the task. */@Controller//Root Access directory@RequestMapping ("/user") Public classuseraction {//@Autowired PrivateUserService UserService; //sub-access directory. User Query page@RequestMapping ("/queryuser") PublicString Queryuser (model model)throwsexception{return"/base/user/queryuser"; } //result set for user query page//finally Datagridresultinfo converts a Java object into a JSON object through @responsebody. //the formal parameter wrapper class will be passed from action to service and then to mapper@RequestMapping ("/queryuser_result") Public@ResponseBody datagridresultinfo Queryuser_result (Sysuserqueryvo sysuserqueryvo)throwsException {//These are all based on the rules of Easyui .Datagridresultinfo datagridresultinfo=NewDatagridresultinfo (); /** Easyui rules here to fill total and rows*/List<SysuserCustom> rows=Userservice.findsysusercustom (SYSUSERQUERYVO); Datagridresultinfo.setrows (rows); Datagridresultinfo.settotal (Rows.size ()); returnDatagridresultinfo; } }
007 Medical Project-Module one: User's search: 3. Action and service for user table queries