小编Aji*_*man的帖子

如何设置Angular 4背景图片?

我正在尝试以下行来设置背景图像.但它不起作用.在我的应用程序中不断设置背景图像的方式是什么.

app.component.html

<div [ngStyle]="{'background' : 'url(./images/trls.jpg)'}">
    <router-outlet></router-outlet>
    <alert></alert>
</div>
Run Code Online (Sandbox Code Playgroud)

javascript angular

18
推荐指数
4
解决办法
7万
查看次数

Velocity 2.0:NoClassDefFoundError:org/apache/velocity/runtime/log/CommonsLogLogChute

在使用 Velocity 2.0 启动我的 Web 应用程序时,我收到以下错误:

Caused by: java.lang.NoClassDefFoundError: 
             org/apache/velocity/runtime/log/CommonsLogLogChute
    at org.springframework.ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:240)
    at org.springframework.ui.velocity.VelocityEngineFactoryBean.afterPropertiesSet(VelocityEngineFactoryBean.java:60)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    ... 34 more
Run Code Online (Sandbox Code Playgroud)

所有依赖关系均已得到满足。我们正在使用

  • slf4j-api-1.7.25.jar
  • slf4j-simple-1.7.25.jar
  • commons-lang3-3.5.jar
  • commons-io-2.5.jar
  • commons-logging-1.2.jar(是的,我们有 Commons-Logging)

在 applicationContext.xml 中,velocityEngine bean 定义如下

<bean id="velocityEngine" 
class="org.springframework.ui.velocity.VelocityEngineFactoryBean"/>
Run Code Online (Sandbox Code Playgroud)

对此有什么想法吗?

我的文件velocity-engine-core-2.0.jar只包含以下.runtime子包:

defaults, directive, parser, resource, visitor
Run Code Online (Sandbox Code Playgroud)

但不是log

更新Spring Velocity Engine bean 声明中的以下 overrideLogging = FALSE 解决了该问题。但为什么?

<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"> 
    <property name="overrideLogging" value="false" />
</bean>
Run Code Online (Sandbox Code Playgroud)

我只是按照https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/ui/velocity/VelocityEngineFactory.html上的提示进行操作, 但不确定发生了什么。

java spring velocity

8
推荐指数
1
解决办法
8645
查看次数

如何从javascript发送音频blob到java spring服务器?

我正在使用我的javascript客户端录制一些音频数据RecordRTC.我想这个音频数据发送到我的春天RestController通过WebSockets.

录制后我的javascript客户端中有一个blob对象: Blob {size: 65859, type: "audio/webm"}

我试图将此blob转换为使用FileReader它的ArrayBuffer对象ArrayBuffer {} byteLength: 65859

我发送ArrayBuffer的javascript代码如下所示:

    const reader = new FileReader();
    reader.addEventListener( 'loadend', () => {
        console.log( 'readerResult', reader.result );
        this.stompClient.send( "/app/hello", {}, reader.result );
    } );

    this.recorder.stopRecording(() => {
        const blob = this.recorder.getBlob();
        reader.readAsArrayBuffer( blob );
        console.log( "blob", blob );
    } );
Run Code Online (Sandbox Code Playgroud)

我的Spring Boot应用程序中的WebSocket端点如下所示:

@MessageMapping("/hello")
public void stream(byte[] input) throws Exception {
    System.out.println("incoming message ...");
    System.out.println(input);
    System.out.println(input.length);
}
Run Code Online (Sandbox Code Playgroud)

这是控制台输出:

incoming message ...
[B@6142acb4
20 …
Run Code Online (Sandbox Code Playgroud)

javascript java spring webrtc spring-boot

4
推荐指数
1
解决办法
3449
查看次数

如何在 angular 5 的纯管道中使用 HTTP 调用

我正在创建一个管道来将一种货币价值转换为另一种货币价值。我正在进行 HTTP 调用以转换值。

@Pipe({
    name: "currencyConverter"
})
export class CurrencyConverterPipe implements PipeTransform {

    transform(value: number, currencyPair: string): number {
        let sourceCurrency = currencyPair.split(":")[0];
        let destinationCurrency = currencyPair.split(":")[1];
        this.currencyConverterService.convert(sourceCurrency, destinationCurrency).subscribe(successData => {
            return successData['fiatValue'] * value;
        }, errorData => {
            console.error(errorData);
        })
    }
}
Run Code Online (Sandbox Code Playgroud)

在 HTML 中

<p> {{ value | currencyConverter:'BTC:USD'}}</p>
Run Code Online (Sandbox Code Playgroud)

我无法在 UI 中看到任何值。当我制作管道时impure,它可以工作,但它正在向服务器发出许多 HTTP 调用。有没有办法在不使用pure: false管道的情况下进行 HTTP 调用

javascript typescript angular

3
推荐指数
1
解决办法
2386
查看次数

Postgres Interval无法使用本机spring数据JPA查询

我创建了一个带间隔的本地查询。当我day在查询中进行硬编码时,查询工作正常:

@Query(value="select * from orders where created_date  < clock_timestamp() - interval ' 5 days'",nativeQuery=true)
Run Code Online (Sandbox Code Playgroud)

但是当我提供这样的数据时@Param

@Query(value="select * from orders where created_date  < clock_timestamp() - interval :day 'days'",nativeQuery=true)
List<Order> getData(@Param("day") String day)
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

由以下原因引起:org.postgresql.util.PSQLException:错误:“ $ 1”或附近的语法错误

java postgresql spring-data-jpa

2
推荐指数
2
解决办法
2187
查看次数

数据不会持久存储到数据库并在控制台中显示空指针异常

我是春季启动的初学者,我使用spring boot在数据库上执行CRUD操作.程序没有错误,但在运行我的应用程序时遇到错误:NullPointerException.

这是我的计划: -

CrudOperationApplication.java

package com;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CrudOperationApplication {

    public static void main(String[] args) {
        SpringApplication.run(CrudOperationApplication.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

DatabaseCon.java

package com;

import java.util.Properties;
import javax.sql.DataSource;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@ComponentScan({ "com" })
@Configuration
@EnableTransactionManagement
@PropertySource(value = { "classpath:application.properties" })
public class DatabaseCon {

        @Autowired
        private Environment environment;

        @Bean
        public LocalSessionFactoryBean sessionFactory() { …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate spring-mvc spring-boot

0
推荐指数
1
解决办法
657
查看次数