zoukankan      html  css  js  c++  java
  • idea 创建springmvc项目

    新建springmvc 项目

    填入名称

    项目结构,会自动下载jar包

    配置Tomcat

    然后启动。。。

    会报错。。。。。。

    是因为相关jar没有导入

    out目录下没有lib

    将jar导入后重新启动服务器,out中已经有lib了,此时已经可以访问首页了

    修改web.xml ,使得springmvc 可以监听所有请求

    修改applicationContext.xml  设置扫描注解的包

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    
        <!-- 注解扫描包 -->
        <context:component-scan base-package="com.ahao"/>
    
        <!-- 启用spring mvc 注解 -->
        <context:annotation-config/>
    
        <!-- 开启注解 -->
        <mvc:annotation-driven/>
    </beans>

    第一个hello

    @RestController
    public class Hello {
        @RequestMapping("/hello")
        public String hello() {
            System.out.println("hello");
            return "hello spring";
        }
    }

    前后端都可以看到输出,说明配置成功

  • 相关阅读:
    Restful API
    事件冒泡
    DOM性能
    获取dom节点的所有子节点
    获取dom节点的父节点
    深拷贝
    Dropdown下拉菜单
    Breadcrumb面包屑
    【vue】----生产环境去除cosole.*
    刷leetcode时,重新认识LinkedList实现栈、队列或者双端队列
  • 原文地址:https://www.cnblogs.com/appium/p/13181520.html
Copyright © 2011-2022 走看看