小编shy*_*yam的帖子

在Spring Boot中的application.properties中获取用户主路径

这应该是一个非常直接的任务,但经过相当多的研究后,我发现很难找到任何方法来做到这一点.

我只想在当前用户的主目录中创建一个日志文件.根据官方文档,我应该修改的变量是logging.filelogging.path.但是我如何获得用户家的价值logging.path呢?

我试过设置它像:

logging.path=#{systemProperties['user.home']}
Run Code Online (Sandbox Code Playgroud)

但没有任何成功.

logging spring spring-el spring-boot

8
推荐指数
3
解决办法
9503
查看次数

逃离百里香的'和'性格

我需要img使用thymeleaf 将图像加载到html 标签上.问题是,图像本身是从一个获取两个参数的URL获得的.

样品:

<img src="/products/images?categoryId=1&image=1" />
Run Code Online (Sandbox Code Playgroud)

麻烦的是,image参数是动态生成的,因此我需要在那里使用百日咳表达式.所以我试过这样的事情:

<img th:src="@{'/products/images?categoryId=1&image=' + ${product.id}}" />
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,我收到以下消息:

Exception parsing document: template="product-list", line 104 - column 59
Run Code Online (Sandbox Code Playgroud)

哪个指向"&"符号出现的位置.现在,我尝试过使用'&' 但随后,网址变得像

/products/images?categoryId=1&amp;image=1
Run Code Online (Sandbox Code Playgroud)

显然,这不会起作用.

那么我怎么用百万富翁制作一个有两个参数的有效链接呢?

hyperlink thymeleaf

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

使用Thymeleaf发布具有多对一关系的数据

我有一个简单的模型类Product,它与表现出多对一的关系ProductCategory

产品类别:

@Entity
@Table(name="product")
public class Product {

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private Long id;

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

@Column(name="description")
private String description;

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="category_id")
private ProductCategory category;

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getPdfUrl() {
    return pdfUrl;
}

public void setPdfUrl(String pdfUrl) {
    this.pdfUrl = pdfUrl;
}

public …
Run Code Online (Sandbox Code Playgroud)

java thymeleaf spring-boot

6
推荐指数
1
解决办法
5930
查看次数

使用Spring Boot和Thymeleaf创建文件下载链接

这可能听起来像一个微不足道的问题,但经过几个小时的搜索,我还没有找到答案.据我所知,问题是我试图FileSystemResource从控制器返回一个,而Thymeleaf希望我提供一个String资源,用它来渲染下一页.但是因为我回来了FileSystemResource,我得到以下错误:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "products/download", template might not exist or might not be accessible by any of the configured Template Resolvers
Run Code Online (Sandbox Code Playgroud)

我使用的控制器映射是:

@RequestMapping(value="/products/download", method=RequestMethod.GET)
public FileSystemResource downloadFile(@Param(value="id") Long id) {
    Product product = productRepo.findOne(id);
    return new FileSystemResource(new File(product.getFileUrl()));
}
Run Code Online (Sandbox Code Playgroud)

我的HTML链接看起来像这样:

<a th:href="${'products/download?id=' + product.id}"><span th:text="${product.name}"></span></a>
Run Code Online (Sandbox Code Playgroud)

我不希望被重定向到任何地方,我只需要在点击链接后下载文件.这实际上是正确的实现吗?我不确定.

java download thymeleaf spring-boot

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

为什么我的Activity始终显示来自GCM通知的相同数据集?

我已经实现了一个简单的GCM客户端,我在更新每次收到新通知时启动的Activity时遇到此问题.每次我发送带有一组参数的通知时,只有我为第一个通知发送的参数才会出现在UI中.当我尝试更改参数时,它们不会显示(再次显示相同的数据).

这是我的GcmIntentService类

public class GcmIntentService extends IntentService {

private static final String TAG = "GcmIntentService";

public static final int NOTIFICATION_ID = 1;
private NotificationManager mNotificationManager;
NotificationCompat.Builder builder;

public GcmIntentService() {
    super("GcmIntentService");
}

@Override
protected void onHandleIntent(Intent intent) {

    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) {

        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
                .equals(messageType)) {
            Log.d(TAG, "GCM error -> MESSAGE_TYPE_SEND_ERROR");
            sendNotification("Send error: " + extras.toString(), "", "",
                    "", "");
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
                .equals(messageType)) {
            Log.d(TAG, "GCM error …
Run Code Online (Sandbox Code Playgroud)

notifications android android-pendingintent google-cloud-messaging

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

如何以编程方式显示/隐藏材料表页脚?

有没有办法使用@Input()变量显示/隐藏材料表页脚?我正在尝试构建一个自定义表格组件,它可能有也可能没有页脚,就像这样

<my-component [showFooter]="false"></my-component>
Run Code Online (Sandbox Code Playgroud)

我想到的只是把一个最明显的事情*ngIfmat-footer-row组件定义内。但是当我尝试使用

<tr *ngIf="showFooter" *matFooterRowDef="displayedColumns; sticky: true"></tr>
Run Code Online (Sandbox Code Playgroud)

或者

<td *ngIf="showFooter" mat-footer-cell *matFooterCellDef>{{someValue}}</td>
Run Code Online (Sandbox Code Playgroud)

我从编译器收到以下错误。

Can't have multiple template bindings on one element. Use only one attribute prefixed with *
Run Code Online (Sandbox Code Playgroud)

如果我无法使用*ngIf.

angular-material angular

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