我的JSP不解释Spring taglib。 请查看代码和结果错误:
视图如下:
<!-- TagLibs -->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
<!DOCTYPE html>
<html>
<body>
<nav>
<ul>
<li><a href="${s:mvcUrl('AHC#HandleArticle').arg(0, Programacao de Computadores).build()}">Programacao de Computadores</a></li>
</ul>
</nav>
</body>
</html>
这是控制器:
package com.filipecanattodev.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.filipecanattodev.model.Discipline;
@Controller
public class ArticlesHandlerController {
@RequestMapping("/HandleArticle")
public ModelAndView HandleArticle(Discipline discipline){
ModelAndView view = new ModelAndView("ListOfArticles");
return view;
}
}
配置如下:
@EnableWebMvc
@ComponentScan(basePackageClasses = { HomeController.class })
public class AppWebConfiguration {
@Bean
public InternalResourceViewResolver InternalResourceViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
return
}
错误如下:
浏览器显示:HTTP状态404 - 请求的资源不可用。
我的网址从http://localhost:8080/filipecanattodev/
更改为http://localhost:8080/filipecanattodev/$%7Bs:mvcUrl('AHC#HandleArticle').arg(0, Programacao de Computadores).build()}
答案 0 :(得分:0)
解决了这个问题,将web.xml的版本从2.3更改为3.0。