IntelliJ IDEA builds a simple SSM framework introductory tutorial (1) --- detailed explanation for beginners

create project

insert image description here
insert image description here

insert image description here

1. Import the jar package required by the SSM framework

insert image description here
insert image description here
insert image description here
insert image description here

2. Project structure configuration

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

3. Create package structure

insert image description here
insert image description here

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <!--    前端控制器 -->
    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc.xml</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>*.action</url-pattern>
    </servlet-mapping>
    <!--   防乱码控制器 -->
    <!-- 解决中文乱码,通过spring提供的过滤器 -->
    <filter>
        <filter-name>CharacterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>utf-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>CharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>



insert image description here
insert image description here
insert image description here

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!--   开启包扫描 <&#45;&#45;-->
    <context:component-scan base-package="cn.tedu"></context:component-scan>
    <!--   开启MVc注解 <&#45;&#45;-->
    <mvc:annotation-driven></mvc:annotation-driven>
    <!--   配置视图解析器 <&#45;&#45;-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

</beans>

4. Development controller Controller layer

insert image description here
insert image description here

5. Project running configuration

insert image description here
insert image description here
insert image description here

6. Display of project operation results

insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_43639180/article/details/117336022