6
回答
SpringMVC 注册功能我这样写有什么问题,求大神指导。

cnotroller



@RequestMapping(value = "aaa")
	public ModelAndView aaa(HttpServletRequest request, User user){
		ModelAndView mav = new ModelAndView();
		Map<String, Object> map = new HashMap<String, Object>(); 
		map.put("login", user.getLogin());//map.put得到帐号
	    map.put("pwd", ConvertUtils.stringToMD5(user.getPwd()));//得到密码(密码用MD5加密)
		if(user.getLogin() == null){
			request.setAttribute("login",user.getLogin());
			request.setAttribute("pwd", user.getPwd());
			mav.setViewName("redirect:/success.jsp");
		} else {
			mav.setViewName("redirect:/test.jsp");
		}
		
		return mav;
	}




service

public User zhuce(Map<String, Object> map){
		try {
			return dao.zhuce(map);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	} 




dao

public User zhuce(Map<String, Object> map);




xml

<insert id="zhuce" parameterType="User" keyProperty="id">
	insert into user(
			u_login,
			u_pwd,)
			values(
			#{login},
			#{pwd},)
	</insert>



运行错误怎么修改


一运行就这样了

这是我随便写的注册页面

<form action="aaa" method = "post">
账户:<input type="text" name="login" id="zhuce"><br>
密码:<input type="password" name="pwd"><br>
<input type="submit" value="注册">
</form>





举报
小小哈哈
发帖于2年前 6回/271阅
顶部