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