Java--SpringMVC

Difference between SpringMVC and Struts2

Compare items

SrpingMVC

Struts2

Advantage

frame entrance

servlet based

filter based

 

frame design ideas

The controller is based on method-level interception, and the processor is designed as a single instance

The controller is based on class-level interception, and the processor is designed to be multi-instance

Due to the design itself, Struts2 can only be designed in multi-instance mode. Compared with springmvc's single-instance mode, Struts2 will consume more server memory.

Parameter passing

Parameters are passed through method parameters

Parameters are passed through member variables of the class

Struts2 passes parameters through member variables, which makes the parameters thread unsafe and may cause concurrency problems.

Integrate with spring

Same company as spring, seamless integration with spring

Requires a modpack

Springmvc can be more easily integrated with spring

 

Execute the flow chart:

1. Processor Mapper

2. Processor adapter 

2-in-1 configuration

<!-- Annotation-driven configuration, instead of separate configuration of mappers and adapters, and supports json response (recommended) -->
<mvc:annotation-driven />

3. View resolvers

<!-- configure view resolver -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- Prefix of configuration view response -->
<property name="prefix" value="/WEB-INF/jsp/" />
<!-- Configuration view response suffix -->
<property name="suffix" value=".jsp" />
</bean>

 以上被称为三大组件。

 

springmvc帮我们默认加载了这些组件:

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324774833&siteId=291194637