发表于: 2017-09-17 23:11:41

1 675


今天完成的事情:先改写了一个注册的界面  把登录和注册分开 他们的区别只是方法不同 

                               需要被拦截的路径相同

<div style= "width:200px;height:150px;margin:0 auto;border:1px solid;">
   <form action="${pageContext.request.contextPath}/login" method="post">
     用户名 <input name="user" type="text"/><br/>
       密码
<input name="password" type="password"/><br/>
       <br/>
       <hr>
       <input type="submit" name="Submit" value="登录">
       <input type="submit" name="Submit3" value="注册">
       <input type="reset" name="Submit2" value="重填">

   </form>
<div style= "width:200px;height:150px;margin:0 auto;border:1px solid;">
   <form action="${pageContext.request.contextPath}/login" method="post">
       用户名 <input name="user" type="text"/><br/>
       密码
<input name="password" type="password"/><br/>
       <br/>
       <hr>

       <input type="submit" name="Submit" value="注册">
       <input type="reset" name="Submit2" value="重填">

   </form>

重新建的项目 不喜欢继续在原来task4的界面改 

先是ssm搭建 这个不多说了 

然后数据库表 是设计好的 

那就model dao  service serviceimpl  然后把sql语句写在mapping.xml里面

这里学习了一个新的用法 用来自动补全可能为空的值 避免插入出现错误

<!-- 对于所有可能为空的列,需要jdbc Type-->
<resultMap id="userMap" type="com.jnshu.model.User">
   <id column="id" property="id" jdbcType="BIGINT"/>
   <result column="username" property="userName"/>
   <result column="password" property="password"/>

   <result column="create_at" property="create_at"/>
   <result column="update_at" property="update_at" jdbcType="BIGINT"/>
</resultMap>
<insert id="insertUser" parameterType="User" useGeneratedKeys="true" keyProperty="id">
   INSERT INTO tssk5(id,username,password,create_at,update_at)values(#{id},#{userName},#{password},#{create_at}),#{update_at});
</insert>

然后就是看controller 

@Autowired
private LoginService loginservice;

@RequestMapping(value = "/login", method = RequestMethod.POST)

public String userRegister(@ModelAttribute User user, HttpServletRequest request) throws UnsupportedEncodingException {
logger.debug(user.toString() + "------------------------");

   loginservice.insertUser(user);

   return "js";


}

来来回回调了半天接口 总是有问题
明天计划的事情:接口继续写 继续调试 
遇到的问题:nonstatic method 'insertUser(com.jnshu.model.User)' cannot be referenced from

       非静态方法不能调用静态方法 

       这个错误以前见过 可惜又忘了 又查了一遍

       果然还是拼写错误或者是符号错误引起的

        这里是因为一个大小写拼错了

改正了一些简单错误后 发现注册不能正常跳转到/123

<form action="${pageContext.request.contextPath}/123" method="post">

这里感觉没写错啊

用postman测也是 /123能够正常传入数据

收获:学会了表单的提交验证  不过还有点问题 再次复习了ssm的搭建

          再次复习了整体的一个思路 

 任务开始时间:9.15

         预计完成时间:9.20

         是否有延期风险:暂无

禅道链接:http://task.ptteng.com/zentao/my-task.html




返回列表 返回列表
评论

    分享到