springMvc环境搭建

阅读更多
web.xml配置:


  web-ljgc
  
	  
	  	action
	  	org.springframework.web.servlet.DispatcherServlet
	  	

	  		contextConfigLocation
	  		classpath:spring-mvc.xml
	  	
	  
	  
	  
	  		action
	  		/ 	
	  
	
	
	
		CharacterEncodingFilter
		org.springframework.web.filter.CharacterEncodingFilter
		
		
			encoding
			utf-8
	   
	
	
	
		CharacterEncodingFilter
		/*	
	
  
    index.html
    index.htm
    index.jsp
    default.html
    default.htm
    default.jsp
  



Spring-mvc.xml配置:



    
    
    
	
	
	
	 
	
	
	
		
		
	
	
	
	
		
	
	
	
	
	
		
		
			
					
			
		
	
	
	
	
	
	
	
		
	
	
	
	
	
	
	
	
	
		
			
				
		
	         				


测试代码:
package com.tosit.ligc.web;

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

@Controller
public class springTest {
	
	@RequestMapping("/login.html")
	
	 public String loginUI() {
		return "login";
	}
	
	@RequestMapping("/print")
	public String print(){
		System.out.println("spring-mvc框架配置成功");
		return "istrue";	
	}	
}



istrue.jsp页面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here


spring-mvc配置成功



login.jsp页面:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here



	
用户名: 密码:


你可能感兴趣的:(java,框架,spring,json)