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
Spring 将字符串传递给jsp,有什么问题吗?_Spring_Jsp_Jstl_Cytoscape Web - Fatal编程技术网

Spring 将字符串传递给jsp,有什么问题吗?

Spring 将字符串传递给jsp,有什么问题吗?,spring,jsp,jstl,cytoscape-web,Spring,Jsp,Jstl,Cytoscape Web,在控制器中,我有一个处理程序方法,该方法应将字符串传递给名为searchResultGraph.jsp的jsp @RequestMapping(value = PATHELEM + "/searchGraph") public String handleGraph(Model model) { String write = writer.getWriteString(); model.addAttribute("write", write);

在控制器中,我有一个处理程序方法,该方法应将字符串传递给名为searchResultGraph.jsp的jsp

@RequestMapping(value = PATHELEM + "/searchGraph")
    public String handleGraph(Model model) {
        String write = writer.getWriteString();
        model.addAttribute("write", write);
        System.out.println(write);
        return PATHELEM + "/searchResultGraph";
    }
jsp如下所示:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="core"%>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <title>Graph View</title>
        <script type="text/javascript" src="<c:url value="/resources/js/json2.min.js" />"></script> <!-- ${pageContext.request.contextPath}/WebContent/WEB-INF/views/ -->
        <script type="text/javascript" src="<c:url value="/resources/js/cytoscapeweb.min.js" />"></script>
        <script type="text/javascript" src="<c:url value="/resources/js/AC_OETags.min.js" />"></script>


        <script language="JavaScript">
            window.onload=function() {
                        // network data could alternatively be grabbed via ajax
                 var xml = '${write}';

                        // init and draw
                        // initialization options
                            var options = {
                                swfPath: "CytoscapeWeb",
                                flashInstallerPath: "playerProductInstall"
                            };

                            var vis = new org.cytoscapeweb.Visualization("cytoscapeweb", options);

                            var draw_options = {
                                // your data goes here
                                network: xml,

                                // show edge labels too
                                edgeLabelsVisible: false,

                                edgeTooltipsEnabled:true,

                                // let's try another layout
                                layout: "circle",

                                // hide pan zoom
                                panZoomControlVisible: true
                            };

                            vis.draw(draw_options);

                        };
        </script>

        <style>
            /* The Cytoscape Web container must have its dimensions set. */
            html, body { height: 100%; width: 100%; padding: 0; margin: 0; }
            #cytoscapeweb { width: 100%; height: 100%; }
        </style>
    </head>
    <body>
        <h1>The Graph</h1>
        <h1>${write}</h1>
        <div id="cytoscapeweb">
             Cytoscape Web will replace the contents of this div with your graph.
             ${write}
        </div>
    </body>
</html>

图形视图
window.onload=function(){
//网络数据也可以通过ajax抓取
var xml='${write}';
//初始化并绘制
//初始化选项
变量选项={
swfPath:“CytoscapeWeb”,
flashInstallerPath:“playerProductInstall”
};
var vis=新的org.cytoscapeweb.Visualization(“cytoscapeweb”,选项);
var draw_选项={
//你的数据在这里
网络:xml,
//也显示边缘标签
edgeLabelsVisible:错误,
edgeTooltipsEnabled:真,
//让我们试试另一种布局
布局:“圆圈”,
//隐藏平移缩放
PanZoomControl可见:真
};
vis.draw(draw_选项);
};
/*Cytoscape Web容器必须设置其尺寸*/
html,正文{高度:100%;宽度:100%;填充:0;边距:0;}
#cytoscapeweb{宽度:100%;高度:100%;}
图表
${write}
Cytoscape Web将用图形替换此div的内容。
${write}
但是,当我尝试调用
${write}
时,没有显示任何内容。我的方法有什么遗漏吗


谢谢

检查是否有名为getWriteString()的方法;在bean类中,如果不创建类名,则在控制器中写入并实例化名为Write的对象,然后将一些字符串传递给该对象,并将其添加到模型中,以由控制器返回该对象

Write write = new Write();
write.getWriteString();

好的,我找到了解决方案:

选项标签中的链接也必须是相对链接

所以不是这个

var options = {
                swfPath: "CytoscapeWeb",
                flashInstallerPath: "playerProductInstall"
              };
我必须写下:

var options = {
                 swfPath: "<c:url value="/resources/js/CytoscapeWeb" />",
                 flashInstallerPath: "<c:url value="resources/js/playerProductInstall" />"
              };
var选项={
swfPath:“”,
flashInstallerPath:“
};

我有一个名为getWriteString()的方法;如果我不这么做,我会有一些例外。。。唯一的问题是,他没有显示我的字符串。但它肯定在某个地方,因为如果不是,它会给我一个错误,比如:使用
ModelMap
找不到名称writery的输入。使用
addObject()
method,这里给出的代码没有问题。我只能要求您确保getWriteString()实际返回的字符串不是空的字符串字符串不是空的。。。这将是一个简单的解决办法!;)试着用c:out代替。从逻辑上讲,这不应该有什么区别,但你永远不知道P