有图片路径 为啥加载不出来

img

img

import static org.hamcrest.Matchers.containsString;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.web.servlet.MockMvc;


@WebMvcTest(HomeController.class)   // <1>
public class HomeControllerTest {



    @Autowired
    private MockMvc mockMvc;   // <2>

    @Test
    public void testHomePage() throws Exception {
        mockMvc.perform(get("/"))    // <3>
                .andExpect(status().isOk())  // <4>
                .andExpect(view().name("home"))  // <5>
                .andExpect(content().string(           // <6>
                        containsString("Welcome to...")));
    }

}



DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Taco Cloudtitle>
head>
<body>
       <h1>Welcome to...h1>
       <img th:scr = "@{/images/TacoCloud.png}"/>
body>
html>

img


网页源代码有图片路径 为啥加载不出来 需要设置图片px?

scr 不应该是src吗

  • 这个问题的回答你可以参考下: https://ask.csdn.net/questions/244122
  • 这篇博客也不错, 你可以看下手机分辨率和网页中的px是一回事吗?
  • 除此之外, 这篇博客: 如何实现微信小程序的横屏及适配中的 使用px进行布局 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 我们可以看到,使用px进行布局时,横屏之后元素并没有变大,所以这种方案是可行的。
    但是,我们可以看到的是,375px在横屏时并没有占满全屏,也就是pxrpx之间并不是简单的1:2的对应关系。
    rpx与px的对应关系
    这里我们不讨论个物理像素、pt、px之间复杂的关系(/ω\)
    所以,使用px布局,也不是那么好用。