Jeecg-boot快速开始

Helloword

Jeecg-boot前后端分离项目快速开发helloword

一、后端代码实现

在 jeecg-boot-module-system 下 src/main/java/org/jeecg/modules 创建 test/JeecgTestController

package org.jeecg.modules.test;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test/jeecgTest")
@Slf4j
public class JeecgTestController {
    @GetMapping(value = "/hello")
    public Result<String> hello() {
        Result<String> result = new Result<String>();
        result.setResult("Hello Jeecgboot!");
        result.setSuccess(true);
        return result;
    }
}

这里需要配置下拦截器ShiroConfig排除

jeecg-boot-base / jeecg-boot-base-core /src/main/java/org/jeecg/config/shiro/ShiroConfig

 在上图中加入配置

//加入配置
filterChainDefinitionMap.put("/test/jeecgTest/hello", "anon");

 启动项目后,访问 http://localhost:8080/jeecg-boot/test/jeecgTest/hello,得到json格式数据:

 

二、前端页面实现

 在 ant-design-vue-jeecg /src/views/jeecg 下创建 helloJeecgboot.vue

<template>
  <div>
    {{message}}
  </div>
</template>

<script>
import {getAction} from '@/api/manage'
export default {
  name: 'helloJeecgboot',
  data(){
    return{
      message:''
    }
  },
  methods:{
    hello(){
      var url = "test/jeecgTest/hello"
      getAction(url).then((res)=>{
        if(res.success){
          this.message = res.result
        }
      })
    }
  },
  created(){
    this.hello()
  }
}
</script>

<style scoped>

</style>

三、配置菜单

1、配置helloJeecgboot菜单:系统管理--菜单管理--新增

 前端组件配置和页面路径一致,

例如:前端组件jeecg/helloJeecgboot   页面路径src/views/jeecg/helloJeecgboot.vue

  

2、用户角色授权:系统管理--角色管理--授权

选择登录的账号 

选择helloJeecgboot授权

 然后在常见案例中选择helloJeecgboot

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值