http://localhost:8080/login的密码和账号的问题

项目场景:

编辑器:IntelliJ IDEA 2020.1
框架:Spring Initializr


问题描述:

启动SpringBoot项目一直停留在http://localhost:8080/login页面

@Override
        public void run() {
            bytes = mmInStream.read(buffer);
            mHandler.obtainMessage(READ_DATA, bytes, -1, buffer).sendToTarget();
        }

原因分析:

可能是项目中pom.xml中,下列代码块导致的问题

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

解决方案一:

输入用户名和密码
用户名默认: user
密码:密码去查看IDEA项目启动时的控制台日志

如下图
红圈出为密码,每个人的不一样,以自己电脑上的为准
红圈出为密码,每个人的不一样,以自己电脑上的为准


解决方案二:

删除pom.xml中的代码块

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

注意:记得,重新启动项目!

  • 10
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
可以在前端vue3项目中新建一个api文件夹,在该文件夹下新建一个auth.js文件,用于封装登录相关的接口。代码如下: ``` import system from './axios' export function login(data) { return system({ url: '/login', method: 'post', data }) } ``` 其中,`data`表示登录表单数据,`system`是我们在axios.js中封装的axios实例。 接着,在登录页面中,我们可以引入刚才封装的`login`接口并调用它。代码如下: ``` <template> <div> <form @submit.prevent="handleLogin"> <label for="username">用户名:</label> <input type="text" id="username" v-model="username"> <label for="password">密码:</label> <input type="password" id="password" v-model="password"> <button type="submit">登录</button> </form> </div> </template> <script> import { login } from '@/api/auth' export default { name: 'LoginPage', data() { return { username: '', password: '' } }, methods: { handleLogin() { const data = { username: this.username, password: this.password } login(data).then(res => { // 登录成功后的操作 this.$router.push('/home') }).catch(error => { // 登录失败后的操作 }) } } } </script> ``` 在上述代码中,我们通过`login`接口向后端发送登录请求,并在登录成功后使用Vue Router将用户重定向到首页。如果登录失败,我们可以在`catch`块中进行相应的处理。 最后,在Vue Router中,我们需要对未登录用户进行拦截,将其重定向到登录页。代码如下: ``` import { getToken } from '@/utils/auth' const routes = [ { path: '/', redirect: '/home' }, { path: '/login', name: 'LoginPage', component: () => import('@/views/LoginPage.vue') }, { path: '/home', name: 'HomePage', component: () => import('@/views/HomePage.vue'), meta: { requiresAuth: true } } ] const router = createRouter({ history: createWebHistory(), routes }) router.beforeEach((to, from, next) => { if (to.meta.requiresAuth) { const token = getToken() if (token) { next() } else { next('/login') } } else { next() } }) export default router ``` 在上述代码中,我们使用了`meta`字段来标记需要登录才能访问的页面,并在`beforeEach`导航守卫中判断用户是否已登录。如果未登录,则将其重定向到登录页。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值