- SpringMvcConfig配置类
// SpringMvcConfigpackage com.itheima.config;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.EnableWebMvc;// Spring配置类@Configuration// 扫描包@ComponentScan("com.itheima.controller")// 万能工具注解@EnableWebMvcpublic class SpringMvcConfig {}// ServletConfigpackage com.itheima.config;import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;// 注意:继承于AbstractAnnotationConfigDispatcherServletInitializerpublic class ServletConfig extends AbstractAnnotationConfigDispatcherServletInitializer { // 设置SpringConfig protected Class<?>[] getRootConfigClasses() { return new Class[]{SpringConfig.class}; } // 设置SpringMvcConfig protected Class<?>[] getServletConfigClasses() { return new Class[]{SpringMvcConfig.class}; } // 设置路径锁定"/"即可 protected String[] getServletMappings() { return new String[]{"/"}; }}
- 数据库对应实体类创建
// Bookpackage com.itheima.domain;public class Book { private Integer id; private String type; private String name; private String description; @Override public String toString() { return "Book{" + "id=" + id + ", type='" + type + '\'' + ", name='" + name + '\'' + ", description='" + description + '\'' + '}'; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; }}
经验总结扩展阅读
-
曾在网上看过这样一个问题:“你觉得两个人相处 这样回你微信的人,请深交一辈子
-
-
-
-
-
-
多行善事|中医该如何治疗前列腺炎,中医方法治疗前列腺炎有效果?
-
-
-
人类|科学家发现22亿年前隧道,人类还未诞生,壁画怎么出现的?
-
-
唇膏福利购 | 当迪奥和古驰都变成半价的时候!谁还不疯啊啊啊啊啊啊!
-
-
-
-
-
-
高空|有种“瘦”叫李菲儿,有着A4腰,柯基臀,不愧是黄晓明的前女友
-
-