2017-02-06 8 views
0

Я пытаюсь включить службу представления, которая уже извлекает данные из моей базы данных на мою страницу index.html. Я использую Spring и Thymeleaf.UseThymeleaf шаблон с извлечением данных из базы данных в другой вид шаблона

Это мой контроллер службы

@Controller 
public class MyServicesController{ 
    @Autowired 
    private ServicesForOurServices servicesForOurServices; 

    @RequestMapping(value = "myservices",method = RequestMethod.GET) 
    public String myServices(Model model){ 
     model.addAttribute("services",servicesForOurServices.listAll()); 
     return "services"; 
    } 

    @RequestMapping(value = "services",method = RequestMethod.GET) 
    public ModelAndView listAll() { 
     ModelAndView modelAndView = new ModelAndView("services"); 
     modelAndView.addObject("services",servicesForOurServices.listAll()); 
     return modelAndView; 
    } 


    @ModelAttribute("services") 
    public Iterable<MyServices> services() { 
     System.out.println("Inside service without model"); 
     return servicesForOurServices.listAll(); 
    } 
} 

И мой вид шаблона службы

<!DOCTYPE html> 
<html xmlns:th="http://www.thymeleaf.org"> 
<head lang="en"> 

    <title>Services</title> 

    <!--/*/ <th:block th:include="fragments/headerinc :: head"></th:block> /*/--> 
</head> 
<body th:fragment="services"> 
    <!--/*/ <th:block th:include="fragments/header :: header"></th:block> /*/--> 
    <div th:if="${not #lists.isEmpty(services)}" class="container-fluid text-center" id="services"> 
     <h2>SERVICES</h2> 
     <h4>What we offer</h4> 
     <div th:each="service : ${services}"> 
      <div class="col-sm-4"> 
       <span th:class="${service.getIcon()}"></span> 
       <h4 th:text="${service.getName()}"></h4> 
       <p th:text="${service.getDescription()}"></p> 
      </div> 
     </div> 

    </div> 

</body> 
</html> 

Затем я включил фрагмент моей index.html

<!--/*/ <th:block th:include="services :: #services"></th:block> /*/--> 

Но index.html обрабатывать только теги h2 и h4, а не div, содержащие услуги

But the index.html only render the h2 and h4 tag and not the div containing the services и если я доступ к services.html все делает прекрасные and if I access the services.html everything renders fine Заранее спасибо

ответ

0

Вы осмотрите элементы из вашего браузера, чтобы увидеть, есть ли какая-либо ошибка выборки фотографии? Подозревание URL-адреса некорректно после рендеринга.

 Смежные вопросы

  • Нет связанных вопросов^_^