Announcement Announcement Module
Collapse
No announcement yet.
methodParameter.getParameterName() is null on implements WebArgumentResolver Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • methodParameter.getParameterName() is null on implements WebArgumentResolver

    in servlet.xml config
    Code:
    <mvc:annotation-driven>
    	<mvc:argument-resolvers>
    		<bean class="com.demo.web.AdminArgumentResolver"  />
    	</mvc:argument-resolvers>
    </mvc:annotation-driven>
    implements WebArgumentResolver
    Code:
    public class AdminArgumentResolver implements WebArgumentResolver {
    	
    	@Override
    	public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) throws Exception {
    		if ("adminId".equals(methodParameter.getParameterName()) && methodParameter.getParameterType() == int.class) {
    			Integer adminId = (Integer) webRequest.getAttribute("sessionAdminId", RequestAttributes.SCOPE_SESSION);
    			if (adminId < 1) {
    				return UNRESOLVED;
    			} else {
    				return adminId;
    			}
    		}
    		return UNRESOLVED;
    	}
    
    }
    methodParameter.getParameterType() is not null
    but methodParameter.getParameterName() is null

    Please help me.

    Can you understand my problem? My English is poor, very sorry.
    Last edited by ionweb; Aug 29th, 2012, 10:20 AM.
Working...
X