小编San*_*ejű的帖子

使用 javascript map() 返回未定义元素的数组

抱歉,这可能很微不足道,但我仍然找不到解决方案:

我有一个包含以下元素的对象:

 0: "A"
 1: "B"
 2: "C"
Run Code Online (Sandbox Code Playgroud)

我想使用 map() 函数将其转换为如下所示:

0: {name: "A"}
1: {name: "B"}
2: {name: "C"}
Run Code Online (Sandbox Code Playgroud)

如果我使用这个:

this.xxx = this.operations.map(obj =>  obj.name);
console.log(this.xxx);
Run Code Online (Sandbox Code Playgroud)

或这个:

this.xxx = this.operations.map(obj => {name:obj} );
 console.log(this.xxx);
Run Code Online (Sandbox Code Playgroud)

xxx 的元素未定义。

javascript json object

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

如何在 Docker 容器内设置“spring.datasource.url”

我创建了一个使用 MySQL 数据库的 Spring Boot 应用程序。我使用 docker-compose 来启动数据库。


services:
  adminer:
    image: adminer
    restart: always
    ports:
      - 8888:8080
  db:
    image: mysql:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 'example' # TODO: Change this      
    volumes:
      - "./config/my.conf:/etc/mysql/conf.d/config-file.cnf"
      - "./data:/var/lib/mysql:rw"
Run Code Online (Sandbox Code Playgroud)

Spring Boot 应用程序(后端)当前不使用 Docker,我在 Eclipse 中运行它。在启动后端之前,我必须 grep Docker 容器的 IPAddress:

docker inspect mysql_ex_db_1 | grep 'IPAddress'
Run Code Online (Sandbox Code Playgroud)

结果是这样的(这个确切的地址会不时改变)

                "IPAddress": "",
                    "IPAddress": "172.21.0.2", 
Run Code Online (Sandbox Code Playgroud)

然后我将这个值设置spring.datasource.url在 Eclipse 的文件中Application.properties

spring.datasource.url=jdbc:mysql://172.21.0.2:3306/employee_management_system?allowPublicKeyRetrieval=true&useSSL=false&createDatabaseIfNotExist=true

Run Code Online (Sandbox Code Playgroud)

之后,我可以在 Eclipse 中启动后端,与数据库的连接就在那里,一切正常。

现在我想将 Backend 的启动从 Eclipse 移至我用来启动数据库的同一个 docker-compose 文件。因此,我构建了一个映像,并附加了 docker-compose 文件:

version: '3.1'

services:
  adminer:
    image: …
Run Code Online (Sandbox Code Playgroud)

mysql spring docker spring-boot docker-compose

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

如何创建无法选择的只读SWT文本?(通过键盘和鼠标)

如何创建无法选择的只读SWT文本?(通过键盘和鼠标)

例如:

Text text = new Text(shell, SWT.BORDER | SWT.READ_ONLY);
text.append("text text text text text text text text text text text text text ");
text.setSelection(10, 60); // If only I could write here something that could turn the text impossible to select, just like if it were a label. 
Run Code Online (Sandbox Code Playgroud)

swt select text readonly

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

使用Spring MVC显示图像和文本(来自数据库)

我想使用Spring MVC 3 显示图像字符串.两者都是我使用Hibernate从数据库中检索的POJO的实例变量.

@Entity
@Table(name = "document")
public class Document {

    //id        

    @Column(name = "name")
    private String name;  // the String

    @Basic(fetch = FetchType.LAZY)
    @Column(name="content")
    private byte [] image;
//getters setters
Run Code Online (Sandbox Code Playgroud)

我想显示使用Spring MVC 3 .jsp页面上的图像显示旁边的字符串.目前我只能通过流式传输并将字符串打印到控制台来显示图片,但这不是我想要的.(当然我可以显示字符串,但是如果我显示字符串,那么我就无法显示图像.)我想在同一页面上同时显示两者.

@RequestMapping(value = "/displayDocument", method = RequestMethod.POST)
    public void displayDocument(@RequestParam("documentId") String documentId, HttpServletResponse response) {

        Document doc = documentService.get(Long.valueOf(documentId));

        System.out.println(doc.getName());

        if (doc.getImage() != null) {
            response.setContentType("image/jpg");
            try {
                response.getOutputStream().write(doc.getImage());
                response.getOutputStream().flush();
                response.getOutputStream().close();
            } catch (IOException e) …
Run Code Online (Sandbox Code Playgroud)

java spring jsp image

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

如何使用 component.css 覆盖 styles.css (Angular)

我在styles.css.modal-content中有一个通用集。这适用于应用程序中的每个模式面板。我想在component.css中覆盖它的宽度。该组件还有一个模式面板,即使我将以下内容放入 component.css 中模式也将保留其全局宽度。

.modal-content{
  border-radius: 0;
  border:none;
  width: 25%;
}
Run Code Online (Sandbox Code Playgroud)

即使我使用!important它也没有任何效果。

我可以做什么来覆盖全局 css 值?

编辑

@Component({
  selector: 'app-base-data',
  templateUrl: './base-data.component.html',
  styleUrls: ['./base-data.component.css']
})
export class BaseDataComponent implements OnInit {
Run Code Online (Sandbox Code Playgroud)

css angular

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

标签 统计

spring ×2

angular ×1

css ×1

docker ×1

docker-compose ×1

image ×1

java ×1

javascript ×1

json ×1

jsp ×1

mysql ×1

object ×1

readonly ×1

select ×1

spring-boot ×1

swt ×1

text ×1