静态资源过滤问题
第一种解决:(优先使用,好处多多)
1.tomcat的项目路径设置为“/”
2.springmvc.xml设置静态资源不过滤
<mvc:annotation-driven/>
<!--设置静态资源不过滤-->
<mvc:resources mapping="/resources/css/**" location="/resources/css/"/>
<mvc:resources mapping="/resources/js/**" location="/resources/js/"/>
<mvc:resources mapping="/resources/images/**" location="/resources/images/"/>
<mvc:resources mapping="/resources/layui/**" location="/resources/layui/"/>
<!--开启springmvc-->
<mvc:default-servlet-handler />
3.调用资源时前面记得加“/”
<link href="/resources/layui/css/layui.css" rel="stylesheet" type="text/css">
第二种解决:(很麻烦的)
1.解决不了,就重新配置tomcat,路径不改为“/”
2.controller类,就是你的表现层那个类,注解@RequestMapping("/account"),
必须加杠(第一种方法可加,可不加)
@Controller
@RequestMapping("/account")
public class AccountController {
@Autowired
private AccountService accountService;
@RequestMapping("/queryAllAccount")
public String queryAllAccount(Model model){
List<Account> list = accountService.queryAllAccount();
for (Account account : list) {
System.out.println(account);
}
model.addAttribute("list",list);
return "success";
}
}
3.调用资源时前面记得加 “…/”,就是返回上一级
<link href="../resources/layui/css/layui.css" rel="stylesheet" type="text/css">
第