嗨我有一个对象数组,其中类别和子类别详细信息在同一个对象中.就像它一样,
public class MyObject {
String categoryCode;
String categeoryCodeDescription;
String subCategoryCode;
String subCategoryCodeDescription;
public MyObject(String categoryCode, String categeoryCodeDescription, String subCategoryCode, String subCategoryCodeDescription) {
this.categoryCode = categoryCode;
this.categeoryCodeDescription = categeoryCodeDescription;
this.subCategoryCode = subCategoryCode;
this.subCategoryCodeDescription = subCategoryCodeDescription;
}
}
List<MyObject> collection = new ArrayList<MyObject>;
collection.add(new My Object("A1", "descA1", "A1A", "descA1A"));
collection.add(new My Object("A1", "descA1", "A1B", "descA1B"));
collection.add(new My Object("A1", "descA1", "A1C", "descA1C"));
collection.add(new My Object("A2", "descA1", "A2A", "descA2A"));
collection.add(new My Object("A2", "descA1", "A2B", "descA2B"));
Run Code Online (Sandbox Code Playgroud)
您是否可以按类别代码进行分组,但可以同时映射到包含描述的对象.所以,如果我有两个类,如..
public class Category {
String categoryCode;
String …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用自定义登录页面在我的 Spring Boot 2 应用程序中实现社交登录。我将 spring-boot-starter-oauth2-client 作为依赖项放置在我的 pom.xml 中。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
然后,我在应用程序属性文件中提供一些客户端 ID 和秘密详细信息。
spring.security.oauth2.client.registration.google.client-id=client-id
spring.security.oauth2.client.registration.google.client-secret=client-secret
Run Code Online (Sandbox Code Playgroud)
使用这个最少的代码,Spring Boot 注册客户端并提供一个登录页面,其中包含通过客户端登录的链接。现在我想提供自己的登录页面,因此我创建了一个安全配置。
@Configuration
@EnableWebSecurity(debug = false)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/auth/**", "/login/oauth2/**", "/login**", "/logout", "/**/*.css", "/**/*.js").permitAll()
.anyRequest().authenticated()
.and()
.oauth2Login().loginPage("/login")
.and()
.logout();
}
}
Run Code Online (Sandbox Code Playgroud)
然后,我提供一个控制器来提供我的自定义登录页面,我现在刚刚将其放入我的 Spring Boot 配置中。
@SpringBootApplication
@Controller
public class SingleSignonApplication {
public static void main(String[] args) {
SpringApplication.run(SingleSignonApplication.class, args);
}
@RequestMapping("/login")
public String loginPage() {
return "login.html"; …Run Code Online (Sandbox Code Playgroud) 嗨,我一直被困在一个看起来像这个简单问题的问题上,来回反复通过SO解决方案似乎并不完全适合我的用例……我有一个角度组件,该模板的模板中包含引导导航药丸,这些是只是用作此特定屏幕中的标签。因此,我有一个“搜索”选项卡和一个“结果”选项卡,执行搜索后,我想激活“结果”选项卡,但无法弄清楚如何从组件中插入引导选项卡。
模板...
<div id="tabs" #tabs>
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" href="#search" data-toggle="tab">Search</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#results" data-toggle="tab">Results</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="search">
search screen
<button type="button" (click)="search()">Search</button>
</div>
<div class="tab-pane active" id="results">results screen</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
然后组件就像..
@Component({
selector: 'app-demo',
templateUrl: './demo.component.html'
})
export class DemoComponent implements OnInit {
@ViewChild('tabs') tabs;
search() {
//perform search. then select the results tab in template.
//this.tabs.selectedIndex = ...
}
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?还是我需要使用在组件中配置的其他选项卡。提前谢谢了。