SpringMVC 无法请求到指定路径 后台无法触发控制器路由方法

在springMVC设置@RequestMapping(’/manager’),千万不要把请求的根路径设置成 ‘manager’。
在springMVC中,如果你的请求根路径设置成‘/manager’,你永远访问不到这个根路径下所有的子路经的。如果你访问根路径‘/manager’,你会看下面的图片,就明白了

不能使用 manager 关键字

在这里插入图片描述
在这里插入图片描述

非常 简单的鸽子使用开发环境 sts 适合不需要配置什么,tomcat也可以加进来, package ghy.webapp.myapp; import java.text.DateFormat; import java.util.Date; import java.util.Locale; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; /** * Handles requests for the application home page. */ @Controller public class HomeController { private static final Logger logger = LoggerFactory.getLogger(HomeController.class); /** * Simply selects the home view to render by returning its name. */ @RequestMapping(value = "/", method = RequestMethod.GET) public String home(Locale locale, Model model) { logger.info("Welcome home! The client locale is {}.", locale); Date date = new Date(); DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); String formattedDate = dateFormat.format(date); model.addAttribute("serverTime", formattedDate ); return "home"; } @RequestMapping(value = "/Two", method = RequestMethod.GET) public String Two( int id,Model model ) { logger.info("two"); System.out.println("hello2 action:"+id); model.addAttribute("name", "huangjie"); //这个只有值没有键的情况下,使用Object的类型作为key,String-->string model.addAttribute("ok"); return "Two"; } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值