1

我的应用程序在开发中运行良好,但是当我将它部署到 tomcat 下拉菜单时停止工作。它在那里,它在鼠标悬停时下降,但它对鼠标点击没有反应。我检查了生成的链接,看起来不错。如果我手动输入 URL,它可以正常工作。我猜这是一些 JavaScript/文件位置问题,但我似乎找不到它。可能遗漏了一些明显的东西。

这是我生成菜单的 main.gsp:

<!doctype html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title><g:layoutTitle default="Grails"/></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="${resource(dir: 'images', file: 'favicon.ico')}" type="image/x-icon">
    <link rel="apple-touch-icon" href="${resource(dir: 'images', file: 'apple-touch-icon.png')}">
    <link rel="apple-touch-icon" sizes="114x114" href="${resource(dir: 'images', file: 'apple-touch-icon-retina.png')}">
    <link rel="stylesheet" href="${resource(dir: 'css', file: 'main.css')}" type="text/css">
    <link rel="stylesheet" href="${resource(dir: 'css', file: 'mobile.css')}" type="text/css">
    <link rel="stylesheet" href="${resource(dir: 'css/bootstrap', file: 'bootstrap.css')}" type="text/css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

    <script type="text/javascript" src="<g:resource dir="/js/bootstrap" file="bootstrap-dropdown.js" />"></script>

    <g:layoutHead/>
    <r:layoutResources />
</head>
<body>
    <div class="navbar-inner">
        <a href="http://grails.org">
            <img src="${resource(dir: 'images', file: 'coming.gif')}" alt="Grails"/>
        </a>
        <sec:ifLoggedIn>
            <div id="headinfo">
                <g:message code="header.user" /> :  ${ sec.loggedInUserInfo(field:'username') }  <br/>
                <g:message code="header.date" /> : <g:formatDate date='${new Date()}' format='E, dd MMM yyyy' locale='${Locale.ENGLISH}'/> <br/>
                <a href="?lang=sr"> <g:img dir="images" file="sr.gif"/>  </a>
                <a href="?lang=en"> <g:img dir="images" file="en.gif"/>  </a>
            </div>
        </sec:ifLoggedIn>
        <h2 id="maintitle"><g:layoutTitle default="Grails"/></h2>
    </div>

    <header class="jumbotron subhead" id="overview">
        <div class="subnav">
            <ul class="nav nav-pills" id="meni">
                <li class="dropdown open">
                    <a href="${createLink(controller:'ticket',action:'index')}"> <g:message code="menu.home" /> </a>
                </li>
                <li class="dropdown open">
                    <g:link controller="ticket" action="list" data-toggle="dropdown"> <g:message code="menu.tickets" /> <b class="caret"></b> </g:link>
                    <ul class="dropdown-menu">
                        <li> <g:link controller="ticket" action="list" data-toggle="dropdown"> <g:message code="menu.ticketList" /> </g:link> </li>
                        <li> <g:link controller="ticket" action="create" data-toggle="dropdown"> <g:message code="menu.createTicket" /> </g:link> </li>
                    </ul>
                </li>


                <li class="dropdown open">
                    <a href="#" data-toggle="dropdown"> <g:message code="menu.admin" /> <b class="caret"></b> </a>
                    <ul class="dropdown-menu">
                        <li> <g:link controller="user" action="list" data-toggle="dropdown"> <g:message code="menu.listUsers" /> </g:link> </li>
                        <li> <g:link controller="company" action="list" data-toggle="dropdown"> <g:message code="menu.listCompanies" /> </g:link> </li>
                        <li> <g:link controller="company" action="create" data-toggle="dropdown"> <g:message code="menu.createCompany" /> </g:link> </li>
                        <li> <g:link controller="project" action="list" data-toggle="dropdown"> <g:message code="menu.projectsList" /> </g:link> </li>
                        <li> <g:link controller="project" action="create" data-toggle="dropdown"> <g:message code="menu.createProjects" /> </g:link> </li>
                        <li> <g:link controller="user" action="invitation" data-toggle="dropdown"> <g:message code="menu.inviteUser" /> </g:link> </li>
                    </ul>
                </li>
                <sec:ifNotLoggedIn>
                    <li class="dropdown open">
                        <g:link controller="login" action="index" data-toggle="dropdown"> <g:message code="menu.login" /> </g:link>
                    </li>
                </sec:ifNotLoggedIn>
                <sec:ifLoggedIn>
                    <li class="dropdown open">
                        <g:link controller="logout" action="index" data-toggle="dropdown"> <g:message code="menu.logout" /> </g:link>
                    </li>
                </sec:ifLoggedIn>
            </ul>
        </div>
    </header>


    <div id="maincontent">
        <g:layoutBody/>
    </div>

    <div class="navbar-inner" id="footerdiv">
        <div id="foottext"> Help Desk </div>
    </div>

    <div id="spinner" class="spinner" style="display:none;"><g:message code="spinner.alt" default="Loading&hellip;"/></div>
    <g:javascript library="application"/>
    <r:layoutResources />

    </div>
</body>

这是一个页眉:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title><g:layoutTitle default="Grails"/></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="${resource(dir: 'images', file: 'favicon.ico')}" type="image/x-icon">
    <link rel="apple-touch-icon" href="${resource(dir: 'images', file: 'apple-touch-icon.png')}">
    <link rel="apple-touch-icon" sizes="114x114" href="${resource(dir: 'images', file: 'apple-touch-icon-retina.png')}">
    <link rel="stylesheet" href="${resource(dir: 'css', file: 'main.css')}" type="text/css">
    <link rel="stylesheet" href="${resource(dir: 'css', file: 'mobile.css')}" type="text/css">
    <link rel="stylesheet" href="${resource(dir: 'css/bootstrap', file: 'bootstrap.css')}" type="text/css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

    <script type="text/javascript" src="<g:resource dir="/js/bootstrap" file="bootstrap-dropdown.js" />"></script>

    <g:layoutHead/>
    <r:layoutResources />
</head>

提前致谢。

编辑:这是 Chrome 控制台中的唯一错误:

Failed to load resource: the server responded with a status of 403 (Forbidden) http://sg.perion.com/v1.1/js/gt.js

而且我注意到,如果我用 right_mouse_button/open_in_new_tab 打开一个下拉菜单链接,它就可以工作。

4

4 回答 4

0

您可能想要使用Grails Bootstrap 插件。这应该处理包含所有必要的引导文件。

于 2012-10-01T13:19:59.047 回答
0

您需要有有效的 Doctype。确保您的 .gsp 和生成的页面源以:

<!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
于 2012-09-18T13:42:43.630 回答
0

改变

<script type="text/javascript" src="<g:resource dir="/js/bootstrap" file="bootstrap-dropdown.js" />"></script>

<script type="text/javascript" src="<g:resource dir="js/bootstrap" file="bootstrap-dropdown.js" />"></script>
于 2012-09-18T19:09:59.503 回答
0

我是 MVC 和 Bootstrap 的新手,在 Bootstrap 3.3.5 下我修改了 bootstrap.css 以恢复子菜单类时遇到了这个问题,但没有修改 bootstrap.min.css。在开发中一切都很好,编译 Debug=True (web.config -->system.web) 和缩小文件被忽略,但是当部署到 Debug=False 的服务器时,缩小版本 (bootstrap.min.css) 覆盖了我的定制版。作为短期修复,我删除了生产环境中的 bootstrap.min.css 文件,但现在将研究更新缩小的 .css 文件。绝对是菜鸟的错误,但我们中的一些人在那里,我希望这对其他人有所帮助。

于 2015-12-09T00:39:55.193 回答