Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将多个SessionAttributes导入modelmap_Java_Spring_Web_Controller_Mapping - Fatal编程技术网

Java 将多个SessionAttributes导入modelmap

Java 将多个SessionAttributes导入modelmap,java,spring,web,controller,mapping,Java,Spring,Web,Controller,Mapping,我对Spring还很陌生,所以如果这个问题看起来很简单或明显,我很抱歉,但我试图寻找这个问题的答案,但这辆巴士找不到它。所以我的问题是如何使用多个SessionAttributes,并用一种方法将它们放到地图中 i、 e.我有一个@Controller,它使用SessionAttributes: @Controller @SessionAttributes({"name", "lastName", "birthDate"}) public class SearchController {

我对Spring还很陌生,所以如果这个问题看起来很简单或明显,我很抱歉,但我试图寻找这个问题的答案,但这辆巴士找不到它。所以我的问题是如何使用多个SessionAttributes,并用一种方法将它们放到地图中

i、 e.我有一个@Controller,它使用SessionAttributes:

@Controller
@SessionAttributes({"name", "lastName", "birthDate"})
public class SearchController {

    @RequestMapping(value = "/your-relatives")
    public String findRelatives(ModelMap model) {
        String name = (String) model.get("name");
        String lastName = (String) model.get("lastName");
        String birthDate = (String) model.get("birthDate");
        if (name.equals("John") && lastName.equals("Johnny")) {
            return "YES";
        }
        return "NO";
    }

}
但是当我试图在if为true的情况下返回“YES”时,我得到了错误——出现了意外错误(type=internalserver error,status=500)。 没有可用的消息


它仅在使用其中一个属性时有效。

您的sessoinAttributes
name
lastName
中到底有什么内容?顺便问一下什么是
?html?name和lastName是从用户登录中获取的字符串值。现在是返回文本的简单hmtl文件。确保作为用户输入的字符串与
John
johny
的大写字母J完全匹配。如果大小写与您无关,您可以使用
name.equalsIgnoreCase(“John”)和&lastName.equalsIgnoreCase(“Johnny”)
但如果大小写不匹配,是否应返回“否”,并插入“是”?因为现在我得到的是错误500,根本没有返回值。从技术上讲,
no
应该是一个错误页面。