在Java开发工程中,注解和XML混合使用已成为很多人和公司的首选了。
今天,我们来看一个功能模块,是本人小长假时,亲自动手实验的。当时想使用Spring+SpringMVC+Mybatis以注解的形式做一个人博客的,后来做了两个模块,实在是没有时间,就搁置了。目前实现了,对文章类型的管理和对文章的管理,这两个模块前段使用的时layui。现在,我们来看一下,这个项目的基本架构如图1。
图1
看完架构了,我来看一下具体的配置吧,首先看一下web.xml的配置。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>springmvc</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application*.xml</param-value>
</context-param>
<servlet>
<description>springMVC核心控制器</description>
<servlet-name>servletDispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:sprin