我想使用 Spring Security 保护 Spring Boot 中“/static/secure”中的所有页面,但我不想使用视图。
我创建了一个登录表单,方法=“POST”,并设置了基于 Java 的配置类以成功转到 /static/secure/main.html。
我希望我可以从特定问题的角度进行处理,不幸的是,我可以找到有关如何进行身份验证的指导的所有内容都使用 Thymeleaf 或视图。我真的只是希望它在成功登录后导航到 /static/secure/main.html,而不是调用视图。有谁知道如何配置 Spring Boot 以在身份验证时转到常规 HTML 页面?
我试图只使用 Spring Security 来处理登录,然后一旦我们进入,应用程序的其余部分将是 Angular,根据需要点击 REST API 端点 - 所以我真的不想要“视图”概念,也不想要 Thymeleaf混合。
任何帮助将非常感激!
谢谢你,丹
到目前为止,我一直在创建直接从 HTTP get 返回的函数,然后调用.subscribe返回值。然而,最近我了解了Promise.all,并且想知道如何使用它来等待两个 HTTP 获取完成。
我目前正在做的示例:
function getCustomerList() {
return this.http.get("http://myapi.com/getCustomerList");
}
function otherFunction() {
this.getCustomerList().subscribe() {
data => {}, err => {}, () => {}
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎工作正常,但我一直想知道我是否可以做这样的事情:
function getCustomerList() {
return this.http.get("http://myapi.com/getCustomerList").subscribe( data => {}, err => {}, () => {});
}
function getVendorList() {
return this.http.get("http://myapi.com/getVendorList").subscribe( data => {}, err => {}, () => {});
}
function getAllInfo() {
var p1 = getCustomerList();
var p2 = getVendorList();
Promise.All([p1, p2]);
console.log("This should not …Run Code Online (Sandbox Code Playgroud) 我试图想出一种方法,只是将SQL Server中的表加载到一个类中,而不必告诉它任何东西.基本上,只需创建类并让它知道要加载什么,基于此.这是我到目前为止所拥有的.
我的问题是,是否有一些方法可以避免硬编码类型,调用reader.readString,reader.readInt32等.基于FieldType?
private Int32? readInt32(SqlDataReader reader, string columnName)
{
Int32? result = null;
if (!reader.IsDBNull(reader.GetOrdinal(columnName)))
{
result = reader.GetInt32(reader.GetOrdinal(columnName));
};
return result;
}
public List<T> readTable(string table, string wherecls, string connStr)
{
List<T> result = new List<T>();
using (SqlConnection connection = new SqlConnection(connStr))
{
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = "select * from " + table;
if (wherecls.Length > 0) command.CommandText += " where " + wherecls;
connection.Open();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{ …Run Code Online (Sandbox Code Playgroud)