抱歉,这可能很微不足道,但我仍然找不到解决方案:
我有一个包含以下元素的对象:
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 的元素未定义。
我创建了一个使用 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) 如何创建无法选择的只读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) 我想使用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) 我在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)