我有这个Scala方法,错误如下.无法转换为Scala列表.
def findAllQuestion():List[Question]={
questionDao.getAllQuestions()
}
Run Code Online (Sandbox Code Playgroud)
类型不匹配; 发现:java.util.List[com.aitrich.learnware.model.domain.entity.Question]必填:
scala.collection.immutable.List[com.aitrich.learnware.model.domain.entity.Question]
'<button id="'+item['id']+'" class="btnDeactivateKeyInChildPremiumCustomer waves-effect waves-light>ok</button>'
Run Code Online (Sandbox Code Playgroud)
我使用上面的代码在jquery里面生成每个函数的按钮.动态创建按钮,当我点击按钮时,它应该显示按钮上的进度.我正在使用这款Ladda Button Loader.
btnDeactivateKeyInChildPremiumCustomerClick : function(event){
var id = event.currentTarget.id;
var btnProgress = Ladda.create(document.querySelector('#'+id));
//btnProgress.start(); or //btnProgress.stop();
}
Run Code Online (Sandbox Code Playgroud)
然后我通过按钮事件处理程序捕获事件处理上面的函数.在该函数中它将创建一个btnProgress对象.之后我可以调用start()或stop()函数.我只在一个按钮的情况下成功地工作,而不是在每个按钮内动态创建按钮.但是在每种情况下,它在执行var btnProgress = Ladda.create(document.querySelector('#'+ id))时显示一些错误;
错误
Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '#22' is not a valid selector.
Run Code Online (Sandbox Code Playgroud) 我已经将keycloak与角度应用程序集成在一起.基本上,前端和后端都在不同的服务器上.Backend应用程序在apache tomcat 8上运行.前端应用程序正在JBoss欢迎内容文件夹上运行.
Angular配置
angular.element(document).ready(function ($http) {
var keycloakAuth = new Keycloak('keycloak.json');
auth.loggedIn = false;
keycloakAuth.init({ onLoad: 'login-required' }).success(function () {
keycloakAuth.loadUserInfo().success(function (userInfo) {
console.log(userInfo);
});
auth.loggedIn = true;
auth.authz = keycloakAuth;
auth.logoutUrl = keycloakAuth.authServerUrl + "/realms/app1/protocol/openid-connect/logout?redirect_uri=http://35.154.214.8/hrms-keycloak/index.html";
module.factory('Auth', function() {
return auth;
});
angular.bootstrap(document, ["themesApp"]);
}).error(function () {
window.location.reload();
});
});
module.factory('authInterceptor', function($q, Auth) {
return {
request: function (config) {
var deferred = $q.defer();
if (Auth.authz.token) {
Auth.authz.updateToken(5).success(function() {
config.headers = config.headers || {};
config.headers.Authorization = 'Bearer ' + …Run Code Online (Sandbox Code Playgroud) 我有一个弹簧启动启用rest api配置了keycloak.
keycloak.realm = demo
keycloak.realmKey = yfdsfdiufuydhf
keycloak.auth-server-url = http://localhost:8080/auth
keycloak.ssl-required = external
keycloak.resource = lib-backend
keycloak.bearer-only = true
keycloak.credentials.secret = a9fa2e60-324b-4508-b33d-84be2a981da3
# Keycloak Enable CORS
keycloak.cors = true
keycloak.securityConstraints[0].securityCollections[0].name = spring secured api
keycloak.securityConstraints[0].securityCollections[0].authRoles[0] = lib_sadmin
Run Code Online (Sandbox Code Playgroud)
上面的代码将api返回给客户端而没有任何问题.但是当我删除领域角色并启用客户端角色时会给出403禁止错误.
您好我想重写默认thymeleaf配置到Web应用程序的自定义文件夹.Thymeleaf依赖项被添加到pom.xml文件中.我想映射到WEB-INF/views/文件夹.
我目前的配置
@Bean
public ThymeleafViewResolver thymeleafViewResolver() {
ThymeleafViewResolver thymeleafViewResolver = new ThymeleafViewResolver();
thymeleafViewResolver.setTemplateEngine(templateEngine());
thymeleafViewResolver.setOrder(1);
return thymeleafViewResolver;
}
@Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
templateEngine.addDialect(new LayoutDialect());
return templateEngine;
}
@Bean
public ServletContextTemplateResolver templateResolver() {
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
templateResolver.setPrefix("/WEB-INF/views/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode("HTML5");
templateResolver.setOrder(1);
templateResolver.setCacheable(false);
return templateResolver;
}
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,它显示以下异常.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$DefaultTemplateResolverConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot find template location: …Run Code Online (Sandbox Code Playgroud) 嗨我正在尝试在postgresql数据库中找到纬度和经度最近的位置.但是当我运行以下查询时,显示列距离不存在.
ERROR: column "distance" does not exist
LINE 1: ... ) ) ) AS distance FROM station_location HAVING distance <...
^
********** Error **********
ERROR: column "distance" does not exist
SQL state: 42703
Character: 218
CREATE TABLE station_location
(
id bigint NOT NULL DEFAULT nextval('location_id_seq'::regclass),
state_name character varying NOT NULL,
country_name character varying NOT NULL,
locality character varying NOT NULL,
created_date timestamp without time zone NOT NULL,
is_delete boolean NOT NULL DEFAULT false,
lat double precision,
lng double precision,
CONSTRAINT …Run Code Online (Sandbox Code Playgroud) 我想从我的旧 Spring Boot 安全应用程序迁移到 keycloak。下面是我的安全配置。
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired
private CustomUserDetailsService customUserDetailsService;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http
.authorizeRequests()
.antMatchers("/*", "/static/**", "/css/**", "/js/**", "/images/**").permitAll()
.antMatchers("/school-admin/*").hasAuthority("SCHOOL_ADMIN").anyRequest().fullyAuthenticated()
.antMatchers("/teacher/*").hasAuthority("TEACHER").anyRequest().fullyAuthenticated()
.anyRequest().authenticated().and()
.formLogin()
.loginPage("/login.html").defaultSuccessUrl("/loginSuccess.html")
.failureUrl("/login.html?error").permitAll().and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout.html")).logoutSuccessUrl("/login.html?logout");
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(customUserDetailsService).passwordEncoder(new BCryptPasswordEncoder());
}
}
Run Code Online (Sandbox Code Playgroud)
我已经安装了 keycloak 并且它在端口 8080 上运行。我发现问题是,我们应该在 keycloak 管理页面上创建角色和用户,但是我当前的系统是,用户和角色都在我的 MySQL 数据库上。我不想在 keycloak 上插入用户和角色以进行身份验证和授权。
我有一段使用 keycloak 和 JS 的代码。除了刷新令牌方法必须在令牌过期时从外部调用之外,代码工作正常。如何在过期时自动刷新令牌。
var keycloak = Keycloak('keycloak.json');
keycloak.init({ onLoad: 'login-required' })
.success(reloadData)
.error(function(errorData) {
document.getElementById('customers').innerHTML = '<b>Failed to load data. Error: ' + JSON.stringify(errorData) + '</b>';
});
var loadData = function () {
document.getElementById('subject').innerHTML = keycloak.subject;
if (keycloak.idToken) {
document.getElementById('profileType').innerHTML = 'IDToken';
document.getElementById('username').innerHTML = keycloak.idTokenParsed.preferred_username;
document.getElementById('email').innerHTML = keycloak.idTokenParsed.email;
document.getElementById('name').innerHTML = keycloak.idTokenParsed.name;
document.getElementById('givenName').innerHTML = keycloak.idTokenParsed.given_name;
document.getElementById('familyName').innerHTML = keycloak.idTokenParsed.family_name;
} else {
keycloak.loadUserProfile(function() {
document.getElementById('profileType').innerHTML = 'Account Service';
document.getElementById('username').innerHTML = keycloak.profile.username;
document.getElementById('email').innerHTML = keycloak.profile.email;
document.getElementById('name').innerHTML = keycloak.profile.firstName + ' ' …Run Code Online (Sandbox Code Playgroud) 嗨,我想使用spring mvc ajax调用下载XLX文件。以下是我对服务器的ajax调用。
$.ajax({
type : 'GET',
url : 'downloadExcel',
beforeSend : function() {
startPreloader();
},
complete: function(){
stopPreloader();
},
success : function(response){
console.log(response);
var blob = new Blob([response], { type: 'application/vnd.ms-excel' });
var downloadUrl = URL.createObjectURL(blob);
var a = document.createElement("a");
a.href = downloadUrl;
a.download = "downloadFile.xlsx";
document.body.appendChild(a);
a.click();
}
});
Run Code Online (Sandbox Code Playgroud)
这是我的服务器代码
@RequestMapping(value = "/downloadExcel", method = RequestMethod.GET)
@ResponseBody
public List<LicenceType> downloadExcel() {
return licenceTypeService.findAllLicenceType();
}
Run Code Online (Sandbox Code Playgroud)
我的代码实际上下载了excel文件,但是在excel表格上它显示为
[Object][Object]
zxing` lib 用于在我的 spring mvc 应用程序中生成二维码。他们很好地生成代码,现在我想要在 qr 图像底部的自定义文本。例如 - - 
我使用的图书馆。
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>2.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我使用的代码
String charset = "UTF-8"; // or "ISO-8859-1"
Map hintMap = new HashMap();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
createQRCode(code,
dirPath ,
charset, hintMap, 200, 200);
public static void createQRCode(String qrCodeData, String filePath, String charset, Map hintMap, int qrCodeheight,
int qrCodewidth) throws WriterException, IOException {
BitMatrix matrix = new MultiFormatWriter().encode(new String(qrCodeData.getBytes(charset), charset),
BarcodeFormat.QR_CODE, qrCodewidth, qrCodeheight, hintMap);
MatrixToImageWriter.writeToFile(matrix, filePath.substring(filePath.lastIndexOf('.') + 1), new File(filePath));
}
Run Code Online (Sandbox Code Playgroud) keycloak ×4
spring-boot ×3
javascript ×2
jquery ×2
ajax ×1
angularjs ×1
backbone.js ×1
java ×1
list ×1
postgresql ×1
scala ×1
spatial ×1
spring-mvc ×1
sql ×1
thymeleaf ×1
zxing ×1