我几乎是休息服务世界的新手,在这里我试图更改输出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) 在资源文件夹下的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)