grails createLink仅在服务器上部署时才会引发错误

时间:2016-09-21 14:58:32

标签: apache tomcat grails

grails版本:3.1.1 groovy版本:2.4.5 jvm版本:1.8.0_25 Apache Tomcat:7.0.70

所以我在主视图中有这个导航:

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Test Your Data<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="${createLink(controller:'testdata', action:'location')}">GIS Data</a></li>
<li><a href="${createLink(controller:'testdata', action:'credit')}">Credit Data</a></li>
<li><a href="${createLink(controller:'testdata', action:'vehicle')}">Axiom Data</a></li>
<li><a href="${createLink(controller:'testdata', action:'license')}">MVR Data</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Add New Data<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="${createLink(controller:'UploadTestData', action:'uploadLocation')}">Location Data</a></li>
<li><a href="${createLink(controller:'UploadTestData', action:'uploadCredit')}">Credit Data</a></li>
<li><a href="${createLink(controller:'UploadTestData', action:'uploadVehicle')}">Vehicle Data</a></li>
<li><a href="${createLink(controller:'UploadTestData', action:'uploadLicense')}">Licence Data</a></li>
</ul>
</li>

当我在我的本地dev和prod上运行它时它工作但是当我构建一个war并将它放在服务器上时,UploadTestData中的所有createlink都不起作用并抛出此错误: javax.servlet.ServletException:无法解析名为'grailsDispatcherServlet'的servlet中名为'/ uploadTestData / uploadGis'的视图

1 个答案:

答案 0 :(得分:0)

尝试使用grails提供的<g:link> </g:link>

E.g

 <li><g:link resource="testdata" action="location">GIS Data</g:link></li>

resource =您的控制器名称。

action =您的控制器操作名称。

更多详情:

http://docs.grails.org/latest/ref/Tags/link.html