我试图在Spring和drools项目中提供静态资源。为了提供静态资源(如图像、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 Status 500 - org.springframework.core.convert.ConversionFailedException:未能从java.lang.String类型转换为int类型以获得值' null ';嵌套的异常是java.lang.IllegalArgumentException:不能将空值分配给基本类型
我的问题是:
(Q1)我得到了一个堆栈溢出question,说明了上述两个之间的区别,我以前没有使用注释驱动的,但它正在工作,就像前面提到的情况一样。
Q2)我有一个this问题,它提到了1和2都是必需的。
(Q3)如果我只使用它,它会在表单加载页面上提供404。
我错过了什么。
我使用spring与spring 6和drools 7。
编辑:
我可以在控制台中看到异常"java.lang.IllegalArgumentException:空值不能分配给基本类型“。为什么这仅适用于原语类型,而对于字符串,它不抛出异常。
发布于 2018-01-02 11:18:23
您可能是直接将表单对象与域对象绑定。因此,当将值绑定到int类型的变量时,它将引发异常。
它不是使用原语类型,而是使用包装类,它也适用于null。
https://stackoverflow.com/questions/48059726
复制相似问题