- 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; }}
经验总结扩展阅读
-
-
在孩子眼中,姥姥和奶奶有什么区别呢?孩子的回答很现实
-
-
-
-
-
-
-
2022五一还能本地游吗 2022五一本地游安全吗
-
-
-
算命的说有横财运_五行缺火家里不利事业运的风水布局
-
-
-
-
-
两个人在一起的时候 女人想你了,会给你这些提示,别视而不见
-
-
一个女人开始对你的态度很好 如果一个女人,渐渐和你疏远了,该怎么办?
-
因为我的身体不怎么的好|出外打工半年后回家,进门一看,我把家砸了