Thymeleaf java template

0

Cześć, mam problem z plikami css w thymeleaf gdy chce je podłączyć do htmla poprzez th:href. Ta templatka będzie używana do maila, który będzie wysyłany przez aplikacje, na razie jest to realizowane w teście, jednak podczas wysylania maila dostaję error message : [THYMELEAF][main] Exception processing template "mailTemplate/index": Link base "/css/style.css" cannot be context relative (/) or page relative unless you implement the org.thymeleaf.context.IWebContext interface (context is of class: org.thymeleaf.context.Context) (mailTemplate/index:13)

oto importy z pliku html

<!-- CSS -->
			<!-- Bootstrap -->
			<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"/>
			<!-- Style -->
			<link rel="stylesheet" href="css/style.css" th:href="@{/css/style.css}" />
			<!-- Icons -->
			<link rel="stylesheet" href="css/flaticon.css" th:href="@{/css/flaticon.css}"/>

Test

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class MailingTests {

		@Autowired WebApplicationContext webContext;
		@Autowired MailHelper helper;
		
		MockMvc mockMvc;
		
		@Before 
		public void setUp() throws Exception{
			mockMvc = MockMvcBuilders.webAppContextSetup(webContext).build();
		}
		
		@Test
		public void testMail() throws Exception {
			helper.sendMail("[email protected]", "dasd", alertMessage("Rower", "x-kom", "11120.00 zł"));
		}

Builder

@Service
public class MailContentBuilder {

	private TemplateEngine templateEngine;

	@Autowired
	public MailContentBuilder(TemplateEngine templateEngine) {
		this.templateEngine = templateEngine;
	}

	public String build(String productName,String shopName, String price) {
		Context context = new Context();
		context.setVariable("productName", productName);
		context.setVariable("shopName", shopName);
		context.setVariable("price", price);
		return templateEngine.process("mailTemplate/index", context);
	}

}
0

a gdzie masz wrzucone cssy? jako static content w folderze webapp/css?
pokaż jak wygląda struktura projektu

swoją drogą bootstrapa też bym sciągnął do projektu

0

oto struktura projektu:

0

spróbuj zamiast Context użyć WebContext?

0

Nie za bardzo mogę podać bo jego konstruktor WebContext(request, response, servletContext) wymaga requestu respona i servletContextu, a nie moge go podać ponieważ to będzie niezależne od webowej strony ponieważ maile będą się wysyłać w tle.

1 użytkowników online, w tym zalogowanych: 0, gości: 1