SpringMVC学习笔记一

阅读更多
学习计算机语言入门都是helloWorld.这次学习SpringMVC也就用helloWorld.来入门吧!
  用到的技术如下:
  • Spring 3.0.5 RELEASE
  • JDK 1.6
  • Maven
  • Eclipse

1. pom的配置如下pom.xml

  4.0.0
  com.david.common
  SpringMVC
  0.0.1-SNAPSHOT
  war
	SpringMVC Maven Webapp
	http://maven.apache.org

	
		3.0.5.RELEASE
	
	
                
                        
                                maven-compiler-plugin
                                
                                        1.6
                                        1.6
                                
                        
            
                maven-war-plugin
                2.0
            
        
    

	

		
		
			org.springframework
			spring-core
			${spring.version}
		

		
			org.springframework
			spring-web
			${spring.version}
		

		
			org.springframework
			spring-webmvc
			${spring.version}
		

	


2.编写Controller
@Controller
@RequestMapping("/welcome")
public class HelloController {
 
	@RequestMapping(method = RequestMethod.GET)
	public String printWelcome(ModelMap model) {
 
		model.addAttribute("message", "Spring 3 MVC Hello World");
		return "hello";
 
	}
 
}

3.编写JSP页面hello.jsp


	

Message : ${message}


4.配置Spring(mvc-dispatcher-servlet.xml)

 
	
 
	
		
			/WEB-INF/pages/
		
		
			.jsp
		
	
 


5.配置web.xml

 
	Spring MVC Application
 
	
		mvc-dispatcher
		
                       org.springframework.web.servlet.DispatcherServlet
                
		1
	
 
	
		mvc-dispatcher
		/
	
 
	
		contextConfigLocation
		/WEB-INF/mvc-dispatcher-servlet.xml
	
 
	
		
                      org.springframework.web.context.ContextLoaderListener
                
	
 



ok 经过上面5步骤,简单的SpringMVC hello World就完成了。
  • SpringMVC.rar (7.7 KB)
  • 下载次数: 2

你可能感兴趣的:(SpringMVC学习笔记一)