- 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; }}
经验总结扩展阅读
-
导语:心仪的他就在眼前 心仪的男人不唐突的4种搭讪方式,教你把握机会,迈出追爱第一步
-
-
-
六款2023年最佳手机推荐 手机好用排行榜2023
-
-
-
2022年10月24日是出火的黄道吉日吗 2022年农历九月廿九宜出火吗
-
再过4天,鸿运当头,高人一等,喜事接踵,横财不断,尽享富贵
-
-
-
-
-
-
-
-
-
-
-
亚麻衣服怎么洗不缩水,亚麻面料的衣服这样清洗不会缩水?
-
疾病 40岁是肠道疾病“高发期”,若想肠道更健康,3个坏习惯要改掉