在春天mvc(5.1.3)我试图做:
val url : String? = null
val matcher: ResultMatcher = MockMvcResultMatchers.forwardedUrl(url)
Run Code Online (Sandbox Code Playgroud)
我得到第二行的编译错误.
来自intellij(kotlinc-jvm 1.3.11):
Error:(230, 56) Kotlin: Null can not be a value of a non-null type String
Run Code Online (Sandbox Code Playgroud)
或者从gradle(kotlin 1.2.71):
Type mismatch: inferred type is String? but String was expected
Run Code Online (Sandbox Code Playgroud)
spring方法的java源代码是:
/**
* Asserts the request was forwarded to the given URL.
* <p>This method accepts only exact matches.
* @param expectedUrl the exact URL expected
*/
public static ResultMatcher forwardedUrl(String expectedUrl) {
return result -> assertEquals("Forwarded URL", expectedUrl, …Run Code Online (Sandbox Code Playgroud)