GVKun编程网logo

ajax 利用 location.href 跳转到页面 user.html 后,user.html 怎么获取后台的 session 值呢?

2

本文的目的是介绍ajax利用location.href跳转到页面user.html后,user.html怎么获取后台的session值呢?的详细情况,我们将通过专业的研究、有关数据的分析等多种方式,同

本文的目的是介绍ajax 利用 location.href 跳转到页面 user.html 后,user.html 怎么获取后台的 session 值呢?的详细情况,我们将通过专业的研究、有关数据的分析等多种方式,同时也不会遗漏关于'Stream' 类型的值不能从函数 'user' 返回,因为它的返回类型是 'Stream?'、angularjs – $state.go(app.location)和$location.path(“app/location”)之间有什么区别?、Config Toolkit 依赖& 分布配置工具包、Document.location.href 和 document.location.replace 的区别的知识。

本文目录一览:

ajax 利用 location.href 跳转到页面 user.html 后,user.html 怎么获取后台的 session 值呢?

ajax 利用 location.href 跳转到页面 user.html 后,user.html 怎么获取后台的 session 值呢?

//此是controller类中方法
@GetMapping(value = "/user/test")
@RequiresRoles("ROLE_ADMIN")
@ResponseBody
public Sys_User test(HttpSession session) {
    System.out.println("进入test方法" + session.getAttribute("user"));
    Sys_User user = (Sys_User) session.getAttribute("user");
    return user ;
}

目前在测试,前端为 login.html,user.html

login.html 的 ajax 如下

function click1() {
    //user可以随意定义
    var user = {};
    user.username = $(''#username'').val();
    user.password = $(''#password'').val();
    $.ajax({
            url: ''/login_account'',
            type: ''post'',

            //   contentType:''application/json;charset=utf-8'',
            // data: user,
            data: user,
            dataType: ''json'',
            success: function (data) {
                var str = "";
                alert("登陆成功!" + data.username);
                location.href = "/user/test";
            },
            error: function (data) {
                alert("进入ERROR!!!")
                alert(data)
            }
        }
    )
}

user.html 不知道用怎么获取,只能写个样式出来,求大佬来指点指点;

另外,个人有几个问题:

1.login.html 的 form 表单用 ajax 提交后,如果用异步刷新的话,感觉改动太大,github 上也找过,没有具体的项目实例,如果只有一个 login.html 的话,其他的数据获取全部用 js 写 ajax 可行吗?

2. 前端有能获取 request,session 等域的框架吗?还是说只有 jsp 这种服务器页面能获取,如果不能获取的话,那目前主流框架都是怎么获取的呢?

望大佬解答小弟疑惑

 

 

'Stream<User?>' 类型的值不能从函数 'user' 返回,因为它的返回类型是 'Stream<User>?'

'Stream' 类型的值不能从函数 'user' 返回,因为它的返回类型是 'Stream?'

如何解决''Stream<User?>'' 类型的值不能从函数 ''user'' 返回,因为它的返回类型是 ''Stream<User>?''?

我在 auth.authStateChanges() 上看到了红线, 错误说:无法从函数“user”返回“Stream”类型的值,因为它的返回类型为“Stream?”。

class Auth {
  final FirebaseAuth auth;

  Auth({required this.auth});

  Stream<User>? get user => auth.authStateChanges(); <-- here

现在更新我收到此错误:

Future<String?> createAccount({required String email,required String password}) async {
    try {
      await auth.createuserWithEmailAndPassword( <-- here **auth**
        email: email.trim(),password: password.trim(),);
      return "Success";
    } on FirebaseAuthException catch (e) {
      return e.message;
    } catch (e) {
      rethrow;
    }
  }

解决方法

这是你更新的课程

import ''package:firebase_auth/firebase_auth.dart'';

class Auth {
  final FirebaseAuth auth;

  Auth({required this.auth});

  Stream<User?> get user => auth.authStateChanges();

  Future<String?> createAccount({required String email,required String password}) async {
    try {
      await FirebaseAuth.instance.createUserWithEmailAndPassword(
        email: email.trim(),password: password.trim(),);
      return "Success";
    } on FirebaseAuthException catch (e) {
      return e.message;
    } catch (e) {
      rethrow;
    }
  }
}

angularjs – $state.go(app.location)和$location.path(“app/location”)之间有什么区别?

angularjs – $state.go(app.location)和$location.path(“app/location”)之间有什么区别?

我最近开始使用离子框架,它有角度的js。要在屏幕之间导航,我使用$ location.path,它的工作非常好。但是,在下载的例子中,我看到$ state.go被用来重定向到一些页面。我想知道两者之间的区别。
$ location服务是在开箱即用的angular.js框架上,允许您管理位置对象(类似于纯JavaScript)。
$ state服务是 ui-router模块的一部分,允许您在整个状态机管理视图时以高级模式管理路由。

如果您使用ui-router,您应该更喜欢使用$ state服务来管理状态/路由,因为状态会抽象出路由的概念,您可以在不更改状态的情况下更改物理路由。

此外,如果您在hashbang mode运行,尤其是在您的html链接中,您可能会遇到更多问题。在这种情况下,最好使用ui-sref而不是ng-href(或只是href)。在我看来,你应该总是以国家而不是路径来思考。显然,如果你知道你在做什么,你可以混合这些服务

依赖& 分布配置工具包" alt="Config Toolkit 依赖& 分布配置工具包">

依赖& 分布配置工具包">Config Toolkit 依赖& 分布配置工具包

Config Toolkit <a href="https://github.com/dangdangdotcom/config-toolkit#%E4%BE%9D%E8%B5%96"></a>依赖<a href="https://github.com/dangdangdotcom/config-toolkit#%E6%A8%A1%E5%9D%97">& 介绍

Config Toolkit 是大型集群和分布式应用配置工具包。Config toolkit 用于简化从本地配置文件到
zookeeper 的迁移。

在大型集群和分布式应用中,配置不宜分散到集群结点中,应该集中管理.

依赖

  • JAVA 7+

  • TOMCAT 7+ for ConfigWeb

模块

  • Config Toolkit - 封装应用属性配置的获取及更新

  • ConfigWeb - 提供web界面维护属性配置,提供配置导入导出功能

特性

  • 集中管理集群配置

  • 实现配置热更新

  • 多配置源支持,内置支持zookeeper、本地文件、http协议

  • Spring集成

  • 本地配置覆盖

  • 配置管理web界面

  • 版本控制,支持灰度发布

  • 支持为配置项添加注释

Quick

Start

zookeeper)load properties from zookeeper

ZookeeperConfigProfile configProfile = new ZookeeperConfigProfile("zoo.host1:8181", "/projectx/modulex", "1.0.0");
    GeneralConfigGroup propertyGroup1 = new ZookeeperConfigGroup(configProfile, "property-group1");

classpath-file)load properties from classpath file

FileConfigProfile configProfile = new FileConfigProfile("UTF8", "properties");
    ConfigGroup configGroup = new FileConfigGroup(configProfile, "classpath:property-group1.properties");

from-classpath-file)load xml properties from classpath file

FileConfigProfile configProfile = new FileConfigProfile("UTF8", "xml");
    ConfigGroup configGroup = new FileConfigGroup(configProfile, "classpath:property-group1.xml");

file)load properties from file

FileConfigProfile configProfile = new FileConfigProfile("UTF8", "properties");
    ConfigGroup configGroup = new FileConfigGroup(configProfile, "file:/Users/yuxuanwang/Work/git/config-toolkit/config-toolkit-demo/src/main/resources/property-group1.properties");

http)load properties from http

FileConfigProfile configProfile = new FileConfigProfile("UTF8", "properties");
    ConfigGroup configGroup = new FileConfigGroup(configProfile, "http://crnlmchina.github.io/config-group.properties");

Config Toolkit <a href="https://github.com/dangdangdotcom/config-toolkit#%E4%BE%9D%E8%B5%96"></a>依赖<a href="https://github.com/dangdangdotcom/config-toolkit#%E6%A8%A1%E5%9D%97">& 官网

依赖&官方网站" rel="nofollow" target="_blank">https://github.com/dangdangdotcom/config-toolkit

Document.location.href 和 document.location.replace 的区别

Document.location.href 和 document.location.replace 的区别

document.location.href 和 document.location.replace 都可以实现从 A 页面切换到 B 页面,但他们的区别是:

用 document.location.href 切换后,可以退回到原页面。

而用 document.location.replace 切换后,不可以通过 “后退” 退回到原页面。

关于 document.location.href 或其他可回退的切换方式,我还发现一个细节,

用个例子来说明:

假设有 A.htm B.htm C.htm 三个页面

A.htm 里有这样一句:document.location.href="b.htm";

b.htm 里有这样一句:document.location.href="c.htm";

注意两个都是可回退的切换。


1: 当从 A 切换到 B 再切换到 C 时,实际内存中保留了三个页面:A、B、C

2: 回退到 B 时,C 页面被清出内存!

3: 再次回退,到 A 页面时,B 页面也被清出内存!

4: 再次向前 (不是用切换而是用向前) 转到 B 页面时,

内存中保留的是 A 和 B

>>> 当一个文档被 location.replace()替换后,它就会从当前的历史对象中移除了

关于ajax 利用 location.href 跳转到页面 user.html 后,user.html 怎么获取后台的 session 值呢?的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于'Stream' 类型的值不能从函数 'user' 返回,因为它的返回类型是 'Stream?'、angularjs – $state.go(app.location)和$location.path(“app/location”)之间有什么区别?、Config Toolkit 依赖& 分布配置工具包、Document.location.href 和 document.location.replace 的区别的相关信息,请在本站寻找。

本文标签: