gpt4 book ai didi

java - MvcUriComponentsBuilder.MethodArgumentBuilder 类型未定义方法 getBuild()

转载 作者:搜寻专家 更新时间:2023-11-01 03:48:54 27 4
gpt4 key购买 nike

从 View 构建 Controller 和方法的 URI 时出现问题。使用 Spring 4.1;我的 Controller

@Controller
@RequestMapping("/produtos")
public class ProductsController {
@Autowired
private ProductDAO productDAO;

@Transactional
@RequestMapping(method=RequestMethod.POST)
public ModelAndView save(Product product){

productDAO.save(product);
return new ModelAndView("redirect:produtos");
}

还有我的 JSP

    <form:form action="${spring:mvcUrl('PC#save').build()}" method="post" >

我在 JSP 上遇到错误:

MvcUriComponentsBuilder.MethodArgumentBuilder 类型未定义方法 getBuild()

如果我使用语法 http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping-uri-templates :

        <form:form action="${spring:mvcUrl(''PC#save'').build()}" method="post" >

在 JSP 上似乎没有错误,但在 web 上:

org.apache.jasper.JasperException: /WEB-INF/views/products/form.jsp (line: 20, column: 1) "${spring:mvcUrl(''PC#save'').build()}" contains invalid expression(s): javax.el.ELException: Failed to parse the expression [${spring:mvcUrl(''PC#save'').build()}]
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:275)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:91)
org.apache.jasper.compiler.Validator$ValidateVisitor.getJspAttribute(Validator.java:1422)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1231)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:879)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1853)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:172)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

我也尝试删除 eclipse 上的 JSP 错误

最佳答案

添加标签库 <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>

关于java - MvcUriComponentsBuilder.MethodArgumentBuilder 类型未定义方法 getBuild(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34206823/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com