2010-04-12 37 views
6

Tôi đã sử dụng khung công tác Spring 3 cho ứng dụng của mình. Tất cả mọi thứ là ok trong khi phát triển trong Netbeans Nhưng tôi cần một tùy chỉnh xây dựng và thực hiện cho cùng Việc xây dựng tạo ra mà không bất kỳ vấn đề , nhưng tôi đã nhận được lỗi sau xảy ra lỗi trong khi gọi phương thức sau đâyGiải quyết vấn đề về lớp học trong Spring 3

@RequestMapping(value = "/security/login", method = RequestMethod.POST) 
public ModelAndView login(@RequestParam String userName, @RequestParam String password, 
    HttpServletRequest request) { 
    ...................... 

Nhưng Có không có vấn đề gì trong khi tạo ra cuộc chiến với netbeans (Tôi chắc chắn đó là về vấn đề biên dịch) bạn có bất kỳ thử nghiệm nào về vấn đề này không ... Có bất kỳ đối số javac bổ sung nào để biên dịch giống nhau (netbeans được sử dụng có nhiệm vụ tùy chỉnh cho biên soạn)

nhập Báo cáo ngoại lệ

nhắn

description The server encountered an internal error() that prevented it from fulfilling this request.

ngoại lệ

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public org.springframework.web.servlet.ModelAndView com.mypackage.security.controller.LoginController.login(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest)]; nested exception is java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either. 
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:659) 
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
com.mypackage.security.controller.AuthFilter.doFilter(Unknown Source) 
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

nguyên nhân gốc rễ

org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public org.springframework.web.servlet.ModelAndView com.mypackage.security.controller.LoginController.login(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest)]; nested exception is java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either. 
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) 
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414) 
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402) 
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) 
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) 
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) 
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
com.mypackage.security.controller.AuthFilter.doFilter(Unknown Source) 
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

nguyên nhân gốc rễ

 
java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either. 
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.getRequiredParameterName(HandlerMethodInvoker.java:618) 
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestParam(HandlerMethodInvoker.java:417) 
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:277) 
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:163) 
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414) 
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402) 
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) 
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) 
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) 
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
com.mypackage.security.controller.AuthFilter.doFilter(Unknown Source) 
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) 

lưu ý Dấu vết ngăn xếp đầy đủ của nguyên nhân gốc có sẵn trong nhật ký Apache Tomcat/6.0.18.

Trả lời

18

Tên đối số được lưu trữ trong mã được biên dịch chỉ khi được biên dịch trong chế độ gỡ lỗi, vì vậy bạn nên biên dịch trong chế độ gỡ lỗi hoặc cung cấp @RequestParam với tên thông số rõ ràng. Cách tiếp cận thứ hai là đáng tin cậy hơn bởi vì nó không phụ thuộc vào môi trường:

@RequestMapping(value = "/security/login", method = RequestMethod.POST) 
public ModelAndView login(@RequestParam("userName") String userName, 
    @RequestParam("password") String password, 
    HttpServletRequest request) { 
    ...................... 
+0

bắt Awesome - Tôi đã xé tóc của tôi ra, nhìn vào JDK, có lẽ máy chủ Hudson tôi đang làm một cái gì đó lập dị ... và nó đã điều nhỏ xíu này. Đây có phải là tài liệu ngay cả ở bất cứ đâu không? – atrain

+0

Chỉ muốn nói điều này đã giúp tôi tiết kiệm nhiều giờ đau đớn, tức giận và các trường hợp sương núi. –

Các vấn đề liên quan