springboot-aboutUpdateOpration-disorder

Target: 

        Today we are going to realize the function which update our employee's informations 

What you need:

        (1) you need a update.html

        (2) in the EmployeeController you need add something else

        (3) in the list.html you also have to add something else

The details:

       (1) first let us put our action on the page which named list.html,please attention the red underline. In the very begining it was a <button> mark, now we have to change it to a mark. Otherwise it do not work.

 

        by the explain about <a> to a conclusion ,we can learn about it can transfer some key fields what we set to the other page or the controllers. 

        and then @{/emp/} means the url which will be caught by the controller and the ${emp.getId()} means the transfer not just taking the url, it also will take the the values.

    (2) now please turn our focus on the EmployeeController.

              first,we can see the annotation @GetMapping() not only caught the url but also can get the id value of the object. And then @PathVariable can get the Id what the list.html send. next we can use the id to get the object of Emplyee, now it's time to send the object to the front end,so here we use model's addAttribute(). what's next we also can get the all departments whch means we can get the department what we need by id index which we set. In a nutshell, we will return the url which means will be caught tomcat and transfer to the update.html

     (3)  In here we can get the value by thymeleaf, but there is a thing we have to pay a attention to..... th:check="${emp.getGenter()==1)" means the deault set number (right) will according the value (left) what it get in the object feild.

so here are the same reanson~, but if we not get the original id, the id will get by auto . so the result what we get and see in the end probably will become update opration to add opration.

but most of time we don't want to show the id

so we need to add this code whose function is hidden the id.

 In here if we not set the date's format we probably can see that sign. and you probably wander about that why the placeholder do not work now, because you have already set the value in the form.

if we add there is another sign we probably can see 

 (4) So in here we will use the method post to sumbit the url.

finally, we just need to save it and redirect to the emps

and the emps will return to the list.html.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Luca-s-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值