以X-gen的Controller为例:
package $#modulePackge#.web; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import $#modulePackge#.service.I$#moduleNameSuperCase#Service; import $#modulePackge#.vo.$#moduleNameSuperCase#Model; import $#modulePackge#.vo.$#moduleNameSuperCase#QueryModel; import com.sishuok.pageutil.Page; import com.sishuok.util.format.DateFormatHelper; import com.sishuok.util.json.JsonHelper; @Controller @RequestMapping(value="/$#moduleName#") public class $#moduleNameSuperCase#Controller { @Autowired private I$#moduleNameSuperCase#Service iservice = null; @RequestMapping(value="toAdd",method=RequestMethod.GET) public String toAdd(){ return "$#moduleName#/add"; } @RequestMapping(value="add",method=RequestMethod.POST) public String add(@ModelAttribute("m") $#moduleNameSuperCase#Model m){ iservice.create(m); return "$#moduleName#/success"; } @RequestMapping(value="toUpdate/{uuid}",method=RequestMethod.GET) public String toUpdate(Model model,@PathVariable("uuid") int uuid){ $#moduleNameSuperCase#Model m = iservice.getByUuid(uuid); model.addAttribute("m", m); return "$#moduleName#/update"; } @RequestMapping(value="update",method=RequestMethod.POST) public String post(@ModelAttribute("m") $#moduleNameSuperCase#Model m){ iservice.update(m); return "$#moduleName#/success"; } @RequestMapping(value="toDelete/{uuid}",method=RequestMethod.GET) public String toDelete(Model model,@PathVariable("uuid") int uuid){ $#moduleNameSuperCase#Model m = iservice.getByUuid(uuid); model.addAttribute("m", m); return "$#moduleName#/delete"; } @RequestMapping(value="delete",method=RequestMethod.POST) public String post(@RequestParam("uuid") int uuid){ iservice.delete(uuid); return "$#moduleName#/success"; } @RequestMapping(value="toList",method=RequestMethod.GET) public String toList(@ModelAttribute("wm")$#moduleNameSuperCase#WebModel wm,Model model){ $#moduleNameSuperCase#QueryModel qm = null; if(wm.getQueryJsonStr()==null || wm.getQueryJsonStr().trim().length()==0){ qm = new $#moduleNameSuperCase#QueryModel(); }else{ String s = wm.getQueryJsonStr(); s = s.replace("-", "%"); qm = ($#moduleNameSuperCase#QueryModel)JsonHelper.str2Object(s, $#moduleNameSuperCase#QueryModel.class); } qm.getPage().setNowPage(wm.getNowPage()); if(wm.getPageShow() > 0){ qm.getPage().setPageShow(wm.getPageShow()); } Page dbPage = iservice.getByConditionPage(qm); // model.addAttribute("wm", wm); model.addAttribute("page", dbPage); return "$#moduleName#/list"; } @RequestMapping(value="toQuery",method=RequestMethod.GET) public String toQuery(){ return "$#moduleName#/query"; } }