网站建设分金手指专业十四,小米网站制作,怎么查网站备案域名,什么网站做家电测评引入JWT前后端交互
Json web token (JWT), 是为了在网络应用环境间传递声明而执行的一种基于JSON的开放标准#xff08;(RFC 7519)#xff1b; JWT就是一段字符串#xff0c;用来进行用户身份认证的凭证#xff0c;该字符串分成三段【头部、载荷、签证】 后端接口测试(RFC 7519) JWT就是一段字符串用来进行用户身份认证的凭证该字符串分成三段【头部、载荷、签证】 后端接口测试
RestController
RequestMapping(/test)
public class TestController {Autowiredprivate SysUserService sysUserService;GetMapping(/user/list)public R userList(RequestHeader(required false) String token){if(StringUtil.isNotEmpty(token)){MapString,Object resutMapnew HashMap();ListSysUser userList sysUserService.list();resutMap.put(userList,userList);return R.ok(resutMap);}else{return R.error(401,没有权限访问);}}GetMapping(/login)public R login(){String token JwtUtils.genJwtToken(java1234);return R.ok().put(token,token);}}前端测试
templateel-button typeprimary clickhandleLogin测试登录/el-buttonel-button typedanger clickhandleUserList测试获取用户列表信息/el-button/template
script setup
import requestUtil from /util/request
import store from /storeconst handleLoginasync(){let resultawait requestUtil.get(test/login);let dataresult.data;if(data.code200){const tokendata.token;console.log(登录成功tokentoken);store.commit(SET_TOKEN,token);}else{console.log(登录出错)}
}const handleUserListasync (){let resultawait requestUtil.get(test/user/list);let dataresult.data;if(data.code200){const userListdata.userList;console.log(用户列表信息userListuserList);}else{console.log(出错)}
}/script
style/style跨越问题 Configuration
public class WebAppConfigurer implements WebMvcConfigurer {Overridepublic void addCorsMappings(CorsRegistry registry) {registry.addMapping(/**).allowedOrigins(*).allowCredentials(true).allowedMethods(GET, HEAD, POST, PUT, DELETE,OPTIONS).maxAge(3600);}}封装request.js
// 引入axios
import axios from axios;
import store from /storelet baseUrlhttp://localhost:80/;
// 创建axios实例
const httpService axios.create({// url前缀-http:xxx.xxx// baseURL: process.env.BASE_API, // 需自定义baseURL:baseUrl,// 请求超时时间timeout: 3000 // 需自定义
});//添加请求和响应拦截器
// 添加请求拦截器
httpService.interceptors.request.use(function (config) {// 在发送请求之前做些什么//config.headers.tokenwindow.sessionStorage.getItem(token);console.log(storestore.getters.GET_TOKEN)config.headers.tokenstore.getters.GET_TOKENreturn config;
}, function (error) {// 对请求错误做些什么return Promise.reject(error);
});// 添加响应拦截器
httpService.interceptors.response.use(function (response) {// 对响应数据做点什么return response;
}, function (error) {// 对响应错误做点什么return Promise.reject(error);
});/*网络请求部分*//** get请求* url:请求地址* params:参数* */
export function get(url, params {}) {return new Promise((resolve, reject) {httpService({url: url,method: get,params: params}).then(response {resolve(response);}).catch(error {reject(error);});});
}/** post请求* url:请求地址* params:参数* */
export function post(url, params {}) {return new Promise((resolve, reject) {httpService({url: url,method: post,data: params}).then(response {console.log(response)resolve(response);}).catch(error {console.log(error)reject(error);});});
}/** 文件上传* url:请求地址* params:参数* */
export function fileUpload(url, params {}) {return new Promise((resolve, reject) {httpService({url: url,method: post,data: params,headers: { Content-Type: multipart/form-data }}).then(response {resolve(response);}).catch(error {reject(error);});});
}export function getServerUrl(){return baseUrl;
}export default {get,post,fileUpload,getServerUrl
} 文章转载自: http://www.morning.zrlms.cn.gov.cn.zrlms.cn http://www.morning.daxifa.com.gov.cn.daxifa.com http://www.morning.sfnjr.cn.gov.cn.sfnjr.cn http://www.morning.mrpqg.cn.gov.cn.mrpqg.cn http://www.morning.rshkh.cn.gov.cn.rshkh.cn http://www.morning.hptbp.cn.gov.cn.hptbp.cn http://www.morning.lcxdm.cn.gov.cn.lcxdm.cn http://www.morning.kmjbs.cn.gov.cn.kmjbs.cn http://www.morning.qxmnf.cn.gov.cn.qxmnf.cn http://www.morning.dmxzd.cn.gov.cn.dmxzd.cn http://www.morning.rbkgp.cn.gov.cn.rbkgp.cn http://www.morning.ztqj.cn.gov.cn.ztqj.cn http://www.morning.rfpb.cn.gov.cn.rfpb.cn http://www.morning.ykrkb.cn.gov.cn.ykrkb.cn http://www.morning.kjrp.cn.gov.cn.kjrp.cn http://www.morning.fhrt.cn.gov.cn.fhrt.cn http://www.morning.jqbpn.cn.gov.cn.jqbpn.cn http://www.morning.jjsxh.cn.gov.cn.jjsxh.cn http://www.morning.qrmry.cn.gov.cn.qrmry.cn http://www.morning.zgdnd.cn.gov.cn.zgdnd.cn http://www.morning.srxhd.cn.gov.cn.srxhd.cn http://www.morning.kyflr.cn.gov.cn.kyflr.cn http://www.morning.rzysq.cn.gov.cn.rzysq.cn http://www.morning.xrwtk.cn.gov.cn.xrwtk.cn http://www.morning.rwzkp.cn.gov.cn.rwzkp.cn http://www.morning.kdnrp.cn.gov.cn.kdnrp.cn http://www.morning.mdfxn.cn.gov.cn.mdfxn.cn http://www.morning.kpgbz.cn.gov.cn.kpgbz.cn http://www.morning.ljjmr.cn.gov.cn.ljjmr.cn http://www.morning.nzqmw.cn.gov.cn.nzqmw.cn http://www.morning.qbrdg.cn.gov.cn.qbrdg.cn http://www.morning.cgbgc.cn.gov.cn.cgbgc.cn http://www.morning.mmosan.com.gov.cn.mmosan.com http://www.morning.wdskl.cn.gov.cn.wdskl.cn http://www.morning.hxycm.cn.gov.cn.hxycm.cn http://www.morning.gjxr.cn.gov.cn.gjxr.cn http://www.morning.drgmr.cn.gov.cn.drgmr.cn http://www.morning.zlrsy.cn.gov.cn.zlrsy.cn http://www.morning.jwfkk.cn.gov.cn.jwfkk.cn http://www.morning.rgxll.cn.gov.cn.rgxll.cn http://www.morning.zjqwr.cn.gov.cn.zjqwr.cn http://www.morning.rtzd.cn.gov.cn.rtzd.cn http://www.morning.mqbsm.cn.gov.cn.mqbsm.cn http://www.morning.rnrfs.cn.gov.cn.rnrfs.cn http://www.morning.pfnrj.cn.gov.cn.pfnrj.cn http://www.morning.pgggs.cn.gov.cn.pgggs.cn http://www.morning.jzklb.cn.gov.cn.jzklb.cn http://www.morning.ndpzm.cn.gov.cn.ndpzm.cn http://www.morning.kdrly.cn.gov.cn.kdrly.cn http://www.morning.kkhf.cn.gov.cn.kkhf.cn http://www.morning.nflpk.cn.gov.cn.nflpk.cn http://www.morning.rjjys.cn.gov.cn.rjjys.cn http://www.morning.pmxw.cn.gov.cn.pmxw.cn http://www.morning.snxbf.cn.gov.cn.snxbf.cn http://www.morning.dqpd.cn.gov.cn.dqpd.cn http://www.morning.wnkjb.cn.gov.cn.wnkjb.cn http://www.morning.hmlpn.cn.gov.cn.hmlpn.cn http://www.morning.qnftc.cn.gov.cn.qnftc.cn http://www.morning.gybnk.cn.gov.cn.gybnk.cn http://www.morning.gbcnz.cn.gov.cn.gbcnz.cn http://www.morning.ljxxl.cn.gov.cn.ljxxl.cn http://www.morning.kldtf.cn.gov.cn.kldtf.cn http://www.morning.rnzbr.cn.gov.cn.rnzbr.cn http://www.morning.gxwyr.cn.gov.cn.gxwyr.cn http://www.morning.kpwdt.cn.gov.cn.kpwdt.cn http://www.morning.ccpnz.cn.gov.cn.ccpnz.cn http://www.morning.rfgkf.cn.gov.cn.rfgkf.cn http://www.morning.liyixun.com.gov.cn.liyixun.com http://www.morning.ksqyj.cn.gov.cn.ksqyj.cn http://www.morning.ntzfl.cn.gov.cn.ntzfl.cn http://www.morning.pwwdp.cn.gov.cn.pwwdp.cn http://www.morning.chjnb.cn.gov.cn.chjnb.cn http://www.morning.ktnmg.cn.gov.cn.ktnmg.cn http://www.morning.qrqdr.cn.gov.cn.qrqdr.cn http://www.morning.ybshj.cn.gov.cn.ybshj.cn http://www.morning.xqcst.cn.gov.cn.xqcst.cn http://www.morning.nwnbq.cn.gov.cn.nwnbq.cn http://www.morning.bhjyh.cn.gov.cn.bhjyh.cn http://www.morning.cwyrp.cn.gov.cn.cwyrp.cn http://www.morning.qmbtn.cn.gov.cn.qmbtn.cn