第一个SpringMVC

1.编写web.xml 放置于  WebContent/WEB-INF 下

 1 
 2 
 3  4 
 5     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "
 6     xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee
 7         http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd ">
 8     
 9     
10         springmvc
11         class>org.springframework.web.servlet.DispatcherServletclass>
12         1
13         
14         
15             contextConfigLocation
16             
17             classpath:springmvc.xml
18         
19     
20 
21     
22     
23         springmvc
24         
25         /
26     
27 
28 

 

2.编写springmvc配置文件:



    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 
        http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
    
    package="user" />

    
    

    
    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"
        id="internalResourceViewResolver">
        
        
        
        
    

 

3.建立处理类

package user;

import java.util.Date;

import javax.xml.crypto.Data;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import converter.date_converter;
import javabean.userbean;

@Controller
@RequestMapping("/user")
public class user {
    @RequestMapping(path="/init")
    public String denglu(userbean user,Data data) {
        System.out.println("成功了"+user);
        System.out.println(data);
        return "init";
    }
    
}

你可能感兴趣的:(第一个SpringMVC)