java mvc.xml_springmvc xml配置

1.maven依赖

org.springframework

spring-webmvc

5.0.5.RELEASE

2.web.xml(在web.xml里面配置DispatcherServlet,可以配置多个)

/p>

"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd" >

app1

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

WEB-INF/app1.xml

1

app1

/

3.DispatcherServlet的配置,默认名字为 {servlet-name}-servlet .xml,可以在里面配置DispatcherServlet的具体细节。

配置的是DispatcherServlet的子上下文。

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"

xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-4.1.xsd

http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

4.编写controller

package com.warofcode.springmvc.web;

import org.springframework.stereotype.Controller;

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

@Controller

public class HelloController {

@RequestMapping("/app1/hello")

public String hello(){

return "hello";

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值