- 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; }}
经验总结扩展阅读
-
不入虎穴焉得虎子是什么意思 不入虎穴焉得虎子的解释
-
-
保湿|这些保湿修复乳液补水保湿、细致毛孔、提亮肤色,你喜欢哪款?
-
李渊驾崩前留给李世民的遗言是什么,为什么李世民要当耳旁风呢?
-
-
202010月10日流星雨几点 是什麽星座的流星雨
-
-
-
-
哥哥按时打钱给老人养老|哥哥按时打钱给老人养老,弟弟赖在家不出门,老人却埋怨哥哥不孝
-
-
-
-
-
-
-
-
-
仲念念|#情感#观点系列插图:电视剧《微微一笑很倾城》剧照01.|你爱的人和爱你的人,你更愿意和谁结婚?
-