java框架环境搭建,环境搭建

## 目录结构

![](https://box.kancloud.cn/d913a01f39e113f340fbe33d0b1b6f39_810x870.png)

## 配置

pom.xml:

~~~

UTF-8

1.8

1.8

5.0.2.RELEASE

org.springframework

spring-context

${spring.version}

org.springframework

spring-web

${spring.version}

org.springframework

spring-webmvc

${spring.version}

javax.servlet

servlet-api

2.5

provided

javax.servlet.jsp

jsp-api

2.0

provided

junit

junit

4.11

test

log4j

log4j

1.2.14

~~~

web.xml:

~~~

/p>

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

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

Archetype Created Web Application

dispatcherServlet

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation //加载配置文件

classpath:springmvc.xml //配置文件路径

1 //启动时机

dispatcherServlet

/

~~~

springmvc.xml:

~~~

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

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

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

xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.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">

~~~

HelloController:

~~~

package com.like.controller;

import org.springframework.stereotype.Controller;

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

@Controller

public class HelloController

{

@RequestMapping(path = "/hello")

public String hello()

{

System.out.println("hello springMVC");

return "success"; //该字符串默认为jsp文件名

}

}

~~~

## 启动流程

* DispatcherServlet对象被创建.

* springmvc.xml被加载.

* HelloController对象被创建.

## 访问流程

前端控制器最为重要.

![](https://box.kancloud.cn/dd728df81df60ffcac82896635bc8a6f_864x501.png)

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值