将参数从gsp传递到grails 3.2.8中的模板gsp内部

时间:2017-05-15 16:11:36

标签: javascript grails

我正在尝试将html标记从gsp传递到模板gsp。但我正在将所需的值传递给模板gsp。附上代码:

**TestPassValueController**
package sample.test
class TestPassValueController {
def groovyPagesTemplateEngine
def index() {
Map testMap = [:]
def test = '<H1 > " hai test page 123 </H1>'       
testMap:[a:"one",b:test]
}
}

**index.gsp**
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title></title>
</head>
<body>
<g:render template='testSample' model="[sample:b]"/>
</body>
</html>

**_testSample.gsp**
<script type="text/javascript">
var sample = ${b};
alert("hai");
alert(sample);
</script>

由于 POOJA

1 个答案:

答案 0 :(得分:0)

您正在将b传递给testSample并将b更改为样本:

  REGROUP FAMILLE      TREND       RMSE    ECART_H
1:      10     A03   48.43853   675.7492  470.45737
2:      10     A04   61.65814   599.2031  795.08575
3:      10     H01  269.07728 12004.1214 6974.29642
4:      10     N01 -170.30563  6282.8133 1455.44291
5:      10     S01  147.61121  2711.0511  529.22545
6:      10     D06   13.64792   167.9315   82.57669

然后在testSample.gsp中,您现在将样本称为b:

<g:render template='testSample' model="[sample:b]"/>

更改<script type="text/javascript"> var sample = ${b}; 或将示例更改为指向model="[b:b]"并将其换成引号,如图所示。