Quickly build springmvc framework under myeclipse

Quickly build springmvc framework under myeclipse

Under the instructions before the start of the construction, springmvc is a framework fired up by training institutions. For many small and medium-sized companies, it is a framework that has to be used, but I think an experienced back-end engineer should not use this over-design. Frame .

1. just create a back-end project and right-click to select Configure faces..->install spring facet

Enter this interface

Next, remove the first two check boxes

Put the code in the display-name under web.xml

<filter>
    <filter-name>spring3encoding</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>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>spring3encoding</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  
  
  <servlet>
    <servlet-name>spring3</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>spring3</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
 

Add the spring3-servlet.xml file to WEB-INF

<?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:p="http://www.springframework.org/schema/p"
    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-3.0.xsd 
           http://www.springframework.org/schema/context 
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springframework.org/schema/mvc 
           http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
    default-autowire="byName"> 
   
   <!--  controller ,   -->
   <context:component-scan base-package="my" > </context:component-scan>    
       
   <!--   -->    
   <mvc:annotation-driven/>    
       
   <!--   -->    
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">    
    <property name="prefix" value="/"/>    
    <property name="suffix" value=".jsp"/><!-- ,   -->    
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>    
   </bean>    
           
    <!--        -->    
    <mvc:default-servlet-handler/>    

</beans> 
 

Note that the package name of the controller I fill my , that is, to write the interface in my bag another name to the front of the xml and web. The servlet names in xml are the same, if you don t understand, just copy and paste

Well, the project is finally initialized, now create a new my package and write a "hello world" interface

operation result

Success, meow