【问题标题】:how to pass a value from model to jsp如何将值从模型传递到jsp
【发布时间】:2018-02-03 07:42:03
【问题描述】:

我有这样的模型

public class Server implements Serializable {

    private String serverIp;

    public String getServerIp() {
        return serverIp;
    }

    public void setServerIp(String serverIp) {
        this.serverIp = serverIp;
    }

}

我需要在 jsp 文件中获取这个 ServerIp。如何做到这一点?

【问题讨论】:

  • 你在网上搜索过that吗?
  • 我做了,我试过这个 但是得到错误。

标签: java jsp spring-mvc


【解决方案1】:

在控制器部分

@ModelAtribute("server")
public Server createServer(){
    Server server = new Server();
    //Set value of your server
    return server;
}

在jsp中

${server.serverIp}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-25
    • 2012-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多