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";
        }
    }

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

  • 相关阅读:
    两元素交换(不借用第三个元素)
    魔兽系统
    员工打卡
    NET框架
    jQuery测试
    Android屏幕适配终结者
    android-auto-scroll-view-pager (无限广告轮播图)
    AndroidImageSlider(图片轮播控件)
    PagerSlidingTabStrip(viewPage滑动菜单)
    怎样把淘宝的数据转到拍拍上
  • 原文地址:https://www.cnblogs.com/appium/p/13181520.html
Copyright © 2011-2022 走看看