HTTP-500错误|运用 和 和

问题描述 投票:0回答:1

我正在尝试在Spring mvc和drools项目中提供静态资源。为了服务静态资源,如images,css和js,我尝试使用以下内容:

1).

    <!-- Enables the Spring MVC @Controller programming model -->
       <mvc:annotation-driven />

   <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <mvc:resources mapping="/resources/js/**" location="/resources/js/"/>

2).

用于扫描我使用的组件:

<!-- Scans within the base package of the application for @Components to configure as beans -->
   <context:component-scan base-package = "package-name" />

我有一个在导航到新页面后加载的表单,在使用1之前我能够加载表单。

当我介绍1然后我得到如下所述的错误:

HTTP状态500 - org.springframework.core.convert.ConversionFailedException:无法从类型[java.lang.String]转换为类型[int]以获取值'null';嵌套异常是java.lang.IllegalArgumentException:无法将null值分配给基本类型

我的问题::

Q1)我得到了一个stackoverflow question,说明了上面两个之间的区别。我之前没有使用过注释驱动,但它的工作情况与前面提到的情况一样。

Q2)我得到了this问题,其中提到了1和2都是必需的。

Q3)如果我只使用它在表单加载页面上给出404。

我错过了什么?

我使用弹簧mvc与春天6和流口水7。

编辑:

我可以在控制台中看到异常“java.lang.IllegalArgumentException:无法将空值赋值给基本类型”。为什么这只适用于原始类型,而String也不是抛出异常。

java spring spring-mvc drools spring-annotations
1个回答
0
投票

可能是你直接用你的域对象绑定表单对象..所以当绑定值到int类型的变量时,它会引发异常..

而不是使用原始类型使用包装类,它也适用于null

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.