加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

spring – javax.el.PropertyNotFoundException:在类型java.l

发布时间:2020-12-15 01:25:58 所属栏目:大数据 来源:网络整理
导读:参见英文答案 c:forEach throws javax.el.PropertyNotFoundException: Property foo not found on type java.lang.String????????????????????????????????????1个 我收到上面的错误. 我要做的是编写一个接收未知数量名称的应用程序,然后在新页面上打印出来.

参见英文答案 > c:forEach throws javax.el.PropertyNotFoundException: Property ‘foo’ not found on type java.lang.String????????????????????????????????????1个
我收到上面的错误.

我要做的是编写一个接收未知数量名称的应用程序,然后在新页面上打印出来.这应该是一个保龄球得分应用程序,但现在我只想得到一个名单.这个想法是让每个名字进入一个玩家对象,然后存储在玩家arraylist中.如果有人可以提供帮助,我将不胜感激.

这是我的控制器代码:

package multiplayergame;

import java.util.ArrayList;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;


@Controller
@SessionAttributes
public class MultiplayerController {

int score;
int roll;
Game game = new Game();
GameProperties gameProps = new GameProperties();
int playerNo = 0;

ArrayList

这包含每个玩家的详细信息:

package multiplayergame;

public class PlayerGame {
private int score;
private int pins;
private String name;
private int roll;
private int nOfPlayers;
private int playerNo;


Game game = new Game();

public Game getGame() {
    return game;
}
public void setGame(Game game) {
    this.game = game;
}   
public int getScore() {
    return score;
}
public void setScore(int score) {
    this.score = score;
}
public int getPins() {
    return pins;
}
public void setPins(int pins) {
    this.pins = pins;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}   
public int getRoll() {
    return roll;
}
public void setRoll(int roll) {
    this.roll = roll;
}
public int getnOfPlayers() {
    return nOfPlayers;
}
public void setnOfPlayers(int nOfPlayers) {
    this.nOfPlayers = nOfPlayers;
}
public int getPlayerNo() {
    return playerNo;
}
public void setPlayerNo(int playerNo) {
    this.playerNo = playerNo;
}
}

这是所有游戏属性的代码,例如得分等.

package multiplayergame;

import java.util.ArrayList;

public class GameProperties {

private int score;
private int pins;
private String name;
private int roll;
private int nOfPlayers;
PlayerGame player;
private ArrayList

以下是我的JSP文件,输出优先:

<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


这是主页:

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
最佳答案
更改此< c:forEach var =“player”items =“players”> to< c:forEach var =“player”items =“${players}”>

作为你引用的“玩家”字符串.它试图在字符串中找到属性名称.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读