jquery easyui实现datagrid表格向数据库中进行增加,修改和删除操作

在account_list.jsp中











  style="width:600px;height:280px;padding:10px 20px" closed="true">
 




在AccountController,java中

/* 
 * Description:
 * 描述账号管理控制页面
 * 
 * History:
 * =============================================================
 * Date                      Version        Memo
 * 2015-6-26下午12:45:09            1.0            Created by HongShuai
 * 
 * =============================================================
 * 
 * Copyright 2015, 迪爱斯通信设备有限公司保留。
 */
@Controller
public class AccountController {


/* Window window=Window(); */
@Autowired
private AccountService accountService;


@RequestMapping(value = "/auth/account", method = { RequestMethod.GET,
RequestMethod.POST })
public ModelAndView getAccountById(int id) {
Account account = accountService.getAccountById(id);
Map model = new HashMap();
model.put("account", account);
return new ModelAndView("auth/account", model);
}


/**
* 跳转增加页面

* @return
*/
@RequestMapping(value = "/auth/account/add", method = { RequestMethod.GET,
RequestMethod.POST })
public String accountAdd() {
return "auth/account/account_add";
}


/**
* 提交增加账户

* @param account
* @return
*/
@RequestMapping(value = "/auth/account/doadd", method = RequestMethod.POST)
public @ResponseBody
boolean doAccountAdd(Account account) {
accountService.saveAccount(account);
return true;
}


/**
* 提交编辑账户

* @param account
* @return
*/
@RequestMapping(value = "/auth/account/doedit", method = {
RequestMethod.GET, RequestMethod.POST })
public @ResponseBody
boolean doaccountEdit(Account account) {
accountService.saveAccount(account);
return true;
}


/**
* 跳转到编辑页面

* @param id
* @return
*/
@RequestMapping(value = "/auth/account/edit/{id}", method = {
RequestMethod.GET, RequestMethod.POST })
public ModelAndView accountEdit(@PathVariable(value = "id") int id) {


Account account = accountService.getAccountById(id);


Map model = new HashMap();


model.put("account", account);


return new ModelAndView("auth/account/account_edit", model);
}


@ResponseBody
@RequestMapping(value = "/auth/account/delete/{id}", method = {
RequestMethod.GET, RequestMethod.POST })
public boolean delAccount(@PathVariable(value = "id") Integer id) {
accountService.delAccount(id);
return true;
}


@RequestMapping(value = "/account/serchAccount", method = { RequestMethod.GET })
public Account serchAccount(String accountname) {
Account account = new Account();
String accountList = account.getAccountName();
if (accountname == accountList) {


}
/* return "auth/account/account_list"; */
return account;
}


/**
* 跳转到帐户管理页面

* @return
*/
@RequestMapping(value = "/account/list", method = { RequestMethod.GET })
public String accountList() {
return "auth/account/account_list";
}


/**
* 获取数据

* @param page
* @param rows
* @return
*/
@RequestMapping(value = "/account/list/data", method = { RequestMethod.GET,
RequestMethod.POST })
public @ResponseBody
Map accountListData(int page, int rows) {
Pageable pageable = new PageRequest(page - 1, rows);
Page accountbypage = accountService.finaAllByPage(pageable);
Map model = new HashMap();
model.put("total", accountbypage.getTotalElements());
model.put("rows", accountbypage.getContent());
return model;
}


@RequestMapping(value = "account/list/searchdata", method = {
RequestMethod.GET, RequestMethod.POST })
public @ResponseBody
Map accountListData(
@ModelAttribute(value = "account") Account account) {


return null;
}


}


在account_add.jsp页面中



modelAttribute="account" action="${APP_PATH}auth/account/doadd">


  • name="accountName"  type="text" data-options="required:true" missingMessage="用户名不能为空" />

  • type="password" data-options="required:true" missingMessage="密码不能为空" />

  • 提交





在account_edit.jsp页面中


<%-- ${account } --%>
modelAttribute="account" action="${APP_PATH}auth/account/doedit">


  •     missingMessage="编号不能为空" type="hidden"  value="${account.id}" />

  •  
  • missingMessage="用户名不能为空" value="${account.accountName}" type="text" />

  •  
  • missingMessage="密码不能为空" value="${account.password}" type="password" />

  •  
  • 提交







你可能感兴趣的:(WEB,前端,三大框架,jquery,easyui)