Servlet.service() for servlet dispatcher threw exception刚学spring mvc ,想实现一个提交表单并保存到数据表的功能,
JSP代码
<form method="POST" action="padd.html" > 权限ID: <input id="aid" type="text" name="aid" /> 权限名称: <input id="aname" type="text" name="aname" /> <input type="submit" value="Submit" /> </form> 毕业论文
Controller 代码
Java code?/** * */package org.clas.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.clas.model.Tpermission; import org.clas.service.TpermissionService; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; /** * @author jiangenbo * * 转移转化平台权限控制管理 */ @Controllerpublic class AuthorityController { /** * @author jiangenbo * * 添加权限信息 */ private TpermissionService tpermissionService; private Tpermission tpermission; @RequestMapping("/padd") public void PermissionAdd(HttpServletRequest request, HttpServletResponse response){ String authid = request.getParameter("aid"); String auname = request.getParameter("aname"); System.out.println("aid==" + authid); System.out.println("aname==" + auname); tpermission.setAuthid(authid); tpermission.setAuthname(auname); tpermissionService.save(this.getTpermission()); //return 1; } public TpermissionService getTpermissionService() { return tpermissionService; } public void setTpermissionService(TpermissionService tpermissionService) { this.tpermissionService = tpermissionService; } public Tpermission getTpermission() { return tpermission; } public void setTpermission(Tpermission tpermission) { this.tpermission = tpermission; } }