SpringMVC配置

2021-05-29 07:02

阅读:499

标签:world   ring   mys   path   handler   enc   resolve   set   request   

SpringMVC配置

web.xml

springMvcorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:springmvc-servlet.xml1springMvc/

springmvc-servlet.xml

controller

package com.luoshen.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class RestController implements Controller {
  public ModelAndView handleRequest(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws Exception {

        ModelAndView mv=new ModelAndView();
        String result="hello world";
        mv.addObject("result",result);
        mv.setViewName("home");
        return mv;
    }
}


//注解方式
package com.luoshen.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

@Controller
public class RestController {
    @RequeMapping("/hello")
    public String hello(){
        return "home";
    }
}



pom.xml

4.0.0com.luoshen
    spring-mvc
    1.0-SNAPSHOTjunit
            junit
            4.12testmysql
            mysql-connector-java
            8.0.18org.mybatis
            mybatis
            3.5.3org.springframework
            spring-webmvc
            5.2.7.RELEASEorg.springframework
            spring-jdbc
            5.2.7.RELEASEorg.aspectj
            aspectjweaver
            1.9.5org.mybatis
            mybatis-spring
            2.0.3javax.servlet
            servlet-api
            2.5src/main/resources**/*.properties**/*.xmltruesrc/main/java**/*.properties**/*.xmltrue

SpringMVC配置

标签:world   ring   mys   path   handler   enc   resolve   set   request   

原文地址:https://www.cnblogs.com/lgx123/p/14771758.html

上一篇:c++ explicit 关键字

下一篇:SpringMVC配置


评论


亲,登录后才可以留言!