发表于: 2017-08-22 20:22:23

2 1073


今天完成的事情:

1.今天一直在弄小课堂,就把小课堂的知识点先整理上来。
首先是Interface的特点:
Java接口中的成员变量默认都是public,static,final——不可修改。
2、Java接口中的方法默认都是public,abstract类型的,没有方法体,不能被实例化
3、接口中没有构造方法,不能被实例化
4、一个接口不能实现(implements)另一个接口,但它可以继承多个其它的接口
5、Java接口必须通过类来实现它的抽象方法
6、当类实现了某个Java接口时,它必须实现接口中的所有抽象方法,否则这个类必须声明为抽象类
7、一个类只能继承一个直接的父类,但可以实现多个接口,间接的实现了多继承.
然后就是为什么要用Interface:
翻了一下午论坛整理出来的,大家讲的都大同小异,
1.接口首先是一种规范, 接口可以为不同类顺利交互提供标准。
2.接口是抽象的,可以根据子类的不同实际需求来实现。也就是可以有多种不同的实现方式,也就是实现了多态。
3.“接口+实现”最常见的优势就是实现类和接口分离,在更换实现类的时候,不用更换接口功能。
4.节约代码量
最后贴上老大在知乎的讲解:
最后才翻到这个,讲的也很细致。

2。继续我的任务四,解决了一个404错误之后,又出来了一个500

一直没搞好,我觉得自己还是应该踏踏实实的回去看一下spring,所以任务我想明天先放一天,认真看一下,就这样
@Controller
public class UserController {
    @Autowired
    private UserService1 userService1;
    @RequestMapping(value = "/User/{id}",method = RequestMethod.GET)
    public String select(@PathVariable("id")long id,Model model){
        User1 user1 =userService1.select(id);
        model.addAttribute("user1",user1);
        return "show";
    }
    //删除
    @RequestMapping(value = "/User/{id}",method = RequestMethod.DELETE)
    public String delete(@PathVariable("id")Long id){
        userService1.delete(id);
        return "show";
public interface User1Mapper {
    public int deleteByPrimaryKey(Long id);
    public User1 selectByPrimaryKey(Long id);
@Service("userService")
public class UserServiceImpl1 implements UserService1 {
    private User1Mapper user1Mapper;
    public int delete(Long id){
      int i=user1Mapper.deleteByPrimaryKey(id);
        return i;
    }
    public User1 select(Long id){
      User1 user1= user1Mapper.selectByPrimaryKey(id);
        return user1;
    }

public interface UserService1{
  public int delete(Long id);
  public User1 select(Long id);
<select id="selectUserByID" parameterType="java.lang.Long" resultType="User1">
  select * from user1 where id = #{id}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  delete from user1 where id=#{id}
</delete>
贴上报错的代码,明天不能解决的话就问。
明天计划的事情:

回去看一下spring 
遇到的问题:

用jetty总是报错。应该是哪里写错了。



返回列表 返回列表
评论

    分享到