thymeleaf引用html_springboot+thymeleaf模版引入静态资源不对问题

我写了一个方法LoginController.java没有任何逻辑直接跳转页面,然后页面样式、js、图片都没有引用进来;下面上下图

先说下问题

页面使用了th标签引入了css/js/图片这些静态资源,

自地址栏直接访问没有问题可以看到

但是我访问http://localhost:8080/users/login(通过方法跳转到页面)出现如下问题

在请求静态资源的时候默认的给我加上了/users,导致资源请求不到,请各位大侠帮忙看看是什么原因,

9c1827c44e6dbcb7bcd5d46a14a2f0e0.png

目录结构:

100234

ce38a21f52d3232492c8ea06661089c4.png

controller代码:

package com.dfyz.controller.admin;

import com.dfyz.Message;

import com.dfyz.entity.Member;

import com.dfyz.service.MemberService;

import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**

* Created by Administrator on 2017/11/16.

*/

@Controller

@RequestMapping("/users")

public class LoginController {

@Resource(name = "memberService")

private MemberService memberService;

@RequestMapping("/login")

public String login(String userName, String password, ModelMap map){

Member member = memberService.find(1L);

// if(member.getPassword().equals(password.trim())){

// return Message.success("成功");

// }

// return Message.error("请核对用户名和密码");

map.addAttribute("member",member);

return "admin/index";

}

}

100234100234

页面代码:(将body中的内容删掉了)

xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">

xxx专用

100234100234

配置文件:

# 端口

#server.port=80

# 自动扫描的包前缀

entitymanager.packagesToScan= com.dfyz

## 自动扫描的包前缀

spring.datasource.url = jdbc:mysql://localhost:3306/test

spring.datasource.username = root

spring.datasource.password = root

spring.datasource.driverClassName = com.mysql.jdbc.Driver

spring.datasource.maxActive=500

# Specify the DBMS

spring.jpa.database = MYSQL

# Show or not log for each sql query

spring.jpa.show-sql = true

# Hibernate ddl auto (create, create-drop, update)

spring.jpa.properties.hibernate.hbm2ddl.auto=update

# spring.jpa.hibernate.ddl-auto = update

# Naming strategy

spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy

# stripped before adding them to the entity manager)

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext

########################################################

###THYMELEAF (ThymeleafAutoConfiguration)

########################################################

#spring.thymeleaf.prefix=classpath:/templates/

#spring.thymeleaf.suffix=.html

#spring.thymeleaf.mode=HTML5

#spring.thymeleaf.encoding=UTF-8

# ;charset= is added

#spring.thymeleaf.content-type=text/html

# set to false for hot refresh

spring.thymeleaf.mode=LEGACYHTML5

spring.thymeleaf.cache=false

# 静态文件请求匹配方式

spring.mvc.static-path-pattern=/**

# 修改默认的静态寻址资源目录

spring.resources.static-locations = classpath:/templates/,classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/

#热部署生效

spring.devtools.restart.enabled=true

cbs.imagesPath=file:/E:/imagesuuuu/

100234100234

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值