Spring mvc spring:url不工作
我有一个无法加载视图名称的标记。我的servlet上下文是test。我定义url:Spring mvc spring:url不工作,spring-mvc,Spring Mvc,我有一个无法加载视图名称的标记。我的servlet上下文是test。我定义url: <spring:url var="editContactUrl" value="/next" /> 有人能启发我吗?谢谢哦,是的,我还尝试在spring中指定上下文:url和相同的结果 编辑:我试图做的只是将引用路由到控制器,它是: @Controller @RequestMapping("/*") public class HomeController { private static fin
<spring:url var="editContactUrl" value="/next" />
有人能启发我吗?谢谢哦,是的,我还尝试在spring中指定上下文:url和相同的结果
编辑:我试图做的只是将引用路由到控制器,它是:
@Controller
@RequestMapping("/*")
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
@RequestMapping(value = "/next", method = RequestMethod.GET)
public String next(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 "next";
}
我不清楚你为什么要使用
@RequestMapping("/*")
在你们班上。
在类级别,您应该定义基本路径。在方法级别,您应该细化更具体的映射。
但是,请尝试:
@RequestMapping("/")
此外,您可以尝试使用:
<c:url var="editContactUrl" value="/next"/>
代替:
<spring:url var="editContactUrl" value="/next"/>
它应该提供类似的功能。我也遇到了同样的问题。似乎spring:url在href中不起作用,我使用了c:url(jstl),它起作用了,问题是为什么?
<c:url var="editContactUrl" value="/next"/>
<spring:url var="editContactUrl" value="/next"/>