小编Pra*_*ash的帖子

XmlElement(name =“ custom_name”)在与其余服务集成的Spring Boot中不起作用

我几乎是休息服务世界的新手,在这里我试图更改输出xml中显示的字段名称。

不确定,如果我遵循正确的方法,任何帮助都是一件好事。

Activity.java

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class Activity {

    private int activityId;
    private int duration;
    private String  description;


    public Activity(int activityId, int duration, String description) {
        super();
        this.activityId = activityId;
        this.duration = duration;
        this.description = description;
    }

    @XmlElement(name="actvID")
    public int getActivityId() {
        return activityId;
    }
    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }
    public int getDuration() {
        return duration;
    }
    public void setDuration(int duration) {
        this.duration = duration;
    }
    public String …
Run Code Online (Sandbox Code Playgroud)

rest jaxb spring-boot spring-restcontroller spring-rest

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

无法在spring boot资源模板中加载css

在资源文件夹下的springboot项目中,我放置了模板.

所有其他html页面都能够加载css,而product.html没有加载.

我正在使用百里叶片来整合.

Github url--:https://github.com/javayp/springbootmvc

ProductController.java

package com.sm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sm.services.ProductService;

@Controller
public class ProductController {

    private ProductService productService;

    @Autowired
    public void setProductService(ProductService productService) {
        this.productService = productService;
    }

    @RequestMapping("/products")
    public String productList(Model model){
        model.addAttribute("products", productService.productList());
        return "productList";
    }

    @RequestMapping("/viewproduct/{id}")
    public String productList(@PathVariable("id") Integer id,Model model){
        System.out.println("Id is------------"+id);
        model.addAttribute("product", productService.getProductById(id));
        return "product";
    }
Run Code Online (Sandbox Code Playgroud)

}

CommonHeader- header.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="common-header">
<title>DevOps</title>

<!-- Bootstrap …
Run Code Online (Sandbox Code Playgroud)

spring-mvc thymeleaf spring-boot

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