IP Address in expression must be the same type as version returned by request



 当我在win7上做 程序开发的时候,在使用哪个spring security的hasIpAddress('192.168.1.0/24')时后爆出异常

java.lang.IllegalArgumentException: Failed to evaluate expression 'hasIpAddress('192.168.1.0/24')'
	org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:13)
	com.mawujun.util.security.CustomWebExpressionVoter.vote(CustomWebExpressionVoter.java:49)
	org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:50)
	org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:203)
	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106)
	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:112)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
	org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
	org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
	com.mawujun.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:124)

 

原因是:

IpAddressMatcher类的matches方法中的

InetAddress remoteAddress = parseAddress(request.getRemoteAddr());

        if (!requiredAddress.getClass().equals(remoteAddress.getClass())) {
            throw new IllegalArgumentException("IP Address in expression must be the same type as " +
                    "version returned by request");
        }

 request.getRemoteAddr获取到的是IPV6的地址 和定义的地址不一样,

解决方案:

修改tomgcat的,让他只支持IPV4

-Djava.net.preferIPv4Stack=true

如下图:



 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
on the result array. To allocate memory dynamically in C, we use the malloc() function. The syntax for using malloc() is as follows: ``` ptr = (castType*) malloc(size); ``` Here, ptr is a pointer of type castType. The malloc() function allocates a block of size bytes of memory, and returns a pointer to the first byte of the block. We can then use this pointer to access the block of memory. In the context of the given problem, we need to allocate memory for a new array of size n, where n is the length of the input array. We can use malloc() to do this as follows: ``` int* result = (int*) malloc(n * sizeof(int)); ``` Here, we first cast the pointer returned by malloc() to an int pointer, as we are allocating memory for an array of integers. We then multiply the size of an int (in bytes) by n, to get the total number of bytes to allocate. Finally, we assign the pointer returned by malloc() to the result variable. The complete code for the function is as follows: ``` int* runningSum(int* nums, int numsSize, int* returnSize){ int* result = (int*) malloc(numsSize * sizeof(int)); int sum = 0; for (int i = 0; i < numsSize; i++) { sum += nums[i]; result[i] = sum; } *returnSize = numsSize; return result; } ``` Here, we first allocate memory for the result array using malloc(). We then iterate through the input array, computing the running sum and storing it in the result array. Finally, we set the value of returnSize to numsSize (as the length of the result array is equal to the length of the input array), and return the result array.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值