我写了一个方法LoginController.java没有任何逻辑直接跳转页面,然后页面样式、js、图片都没有引用进来;下面上下图
先说下问题
页面使用了th标签引入了css/js/图片这些静态资源,
自地址栏直接访问没有问题可以看到
但是我访问http://localhost:8080/users/login(通过方法跳转到页面)出现如下问题
在请求静态资源的时候默认的给我加上了/users,导致资源请求不到,请各位大侠帮忙看看是什么原因,
目录结构:
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";
}
}
页面代码:(将body中的内容删掉了)
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
xxx专用配置文件:
# 端口
#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/