Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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 Spring MVC Model.containsAttribute调用的方法不是访问器方法_Java_Spring_Spring Mvc - Fatal编程技术网

Java Spring MVC Model.containsAttribute调用的方法不是访问器方法

Java Spring MVC Model.containsAttribute调用的方法不是访问器方法,java,spring,spring-mvc,Java,Spring,Spring Mvc,我将回到我在2016年写的一些代码,现在运行它,当调用以下控制器方法时,它在最后一行失败 @RequestMapping(value = "", method = RequestMethod.GET, produces = "text/html") public String getCharacterSheet(@PathVariable("author") String author, @PathVariable("game") String game, @PathVariab

我将回到我在2016年写的一些代码,现在运行它,当调用以下控制器方法时,它在最后一行失败

    @RequestMapping(value = "", method = RequestMethod.GET, produces = "text/html")
    public String getCharacterSheet(@PathVariable("author") String author, @PathVariable("game") String game, @PathVariable("version") String version, Model model, HttpServletRequest request, @AuthenticationPrincipal String currentUser) {
        try {
            PluginDescription description = new PluginDescription(URLDecoder.decode(author, "UTF-8"),
                    URLDecoder.decode(game, "UTF-8"),
                    URLDecoder.decode(version, "UTF-8"));
            Optional<GamePlugin<Character>> plugin = plugins.getPlugin(description);
            if (!plugin.isPresent()) {
                throw new MissingPluginException(description);
            }
            CharacterDataWrapper wrapper;
            if (model.containsAttribute("character-wrapper")) {
@RequestMapping(value=”“,method=RequestMethod.GET,products=“text/html”)
公共字符串getCharacterSheet(@PathVariable(“作者”)字符串作者、@PathVariable(“游戏”)字符串游戏、@PathVariable(“版本”)字符串版本、模型模型、HttpServletRequest请求、@AuthenticationPrincipal String currentUser){
试一试{
PluginDescription description=新的PluginDescription(URLDecover.decode(作者,“UTF-8”),
URLDecover.decode(游戏“UTF-8”),
解码(版本,“UTF-8”);
可选插件=plugins.getPlugin(说明);
如果(!plugin.isPresent()){
抛出新的MissingPluginException(描述);
}
CharacterDataWrapper;
if(model.containsAttribute(“字符包装器”)){
发生的例外是

java.lang.IllegalArgumentException: Invoked method public abstract boolean org.springframework.ui.Model.containsAttribute(java.lang.String) is no accessor method!
    org.springframework.util.Assert.notNull(Assert.java:115)
    org.springframework.data.projection.MapAccessingMethodInterceptor$Accessor.<init>(MapAccessingMethodInterceptor.java:97)
    org.springframework.data.projection.MapAccessingMethodInterceptor.invoke(MapAccessingMethodInterceptor.java:62)
    org.springframework.data.projection.ProjectingMethodInterceptor.invoke(ProjectingMethodInterceptor.java:75)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    org.springframework.data.projection.ProxyProjectionFactory$TargetAwareMethodInterceptor.invoke(ProxyProjectionFactory.java:218)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    com.sun.proxy.$Proxy134.containsAttribute(Unknown Source)
    io.github.thisisnozaku.charactercreator.controllers.games.GamePagesController.getCharacterSheet(GamePagesController.java:77)
java.lang.IllegalArgumentException:调用的方法public abstract boolean org.springframework.ui.Model.containsAttribute(java.lang.String)不是访问器方法!
org.springframework.util.Assert.notNull(Assert.java:115)
org.springframework.data.projection.MapAccessingMethodInterceptor$Accessor.(MapAccessingMethodInterceptor.java:97)
org.springframework.data.projection.MapAccessingMethodInterceptor.invoke(MapAccessingMethodInterceptor.java:62)
org.springframework.data.projection.ProjectingMethodInterceptor.invoke(ProjectingMethodInterceptor.java:75)
org.springframework.aop.framework.ReflectiveMethodInvocation.procement(ReflectiveMethodInvocation.java:179)
org.springframework.data.projection.ProxyProjectionFactory$targetWareMethodInterceptor.invoke(ProxyProjectionFactory.java:218)
org.springframework.aop.framework.ReflectiveMethodInvocation.procement(ReflectiveMethodInvocation.java:179)
org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
org.springframework.aop.framework.ReflectiveMethodInvocation.procement(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
com.sun.proxy.$Proxy134.containsAttribute(未知来源)
io.github.thisisnozaku.charactercreator.controllers.games.games.gamespagescontroller.getCharacterSheet(gamespagescontroller.java:77)

有一件事我不明白,为什么模型似乎是一个代理,它包装了一个
映射
,而不是
模型的一个实现

,我无法确定这一点的真正原因。然而,在检查我的Gradle依赖关系时,我注意到,Spring预期有多个版本

将我的Spring Boot版本升级到最新的1.5.x版本解决了这个问题