【问题标题】:Missing html elements on production server生产服务器上缺少 html 元素
【发布时间】:2017-02-08 14:37:15
【问题描述】:

我正在开发一个 JHipster 生成的 Angular + Spring + Java + HTML5 应用程序

我有一个问题在我之前解决过的几个项目中不断出现,但我希望能够真正解决它

我有以下 html 模板:

<div class="form-group row">
    <label class="control-label col-md-2">ID</label>
    <div class="col-md-4">
        <input type="text" class="form-control" id="id" name="id"
               ng-model="orgLabAMR.id" readonly/>
    </div>
    <label class="control-label col-md-2">organism</label>
    <div class="col-md-4">
        <input type="text" class="form-control"
               placeholder="Search"
               ng-model="orgLabAMR.organism"
               uib-typeahead="organism as organism.organismName for organism in organisms | filter:$viewValue | limitTo:8"
               typeahead-editable="false"/>
    </div>
</div>
<div class="form-group row">
    <label class="control-label col-md-2" for="field_conventionalBloodCultureMethods">Conventional Blood Culture
        Methods</label>
    <div class="col-md-4">
        <select class="form-control" name="field_conventionalBloodCultureMethods" id="field_conventionalBloodCultureMethods" ng-model="orgLabAMR.conventionalBloodCultureMethods"
                ng-options="convBloodCulture as convBloodCulture for convBloodCulture in convBloodCultures"/>
    </div>

    <label class="control-label col-md-2" for="field_automatisedBloodCultureMethods">Automatised Blood Culture
        Methods</label>
    <div class="col-md-4">
        <select class="form-control" id="field_automatisedBloodCultureMethods" ng-model="orgLabAMR.automatisedBloodCultureMethods"
                ng-options="autoBloodCultMethod as autoBloodCultMethod for autoBloodCultMethod in autoBloodCultMethods"/>
    </div>
</div>
<div class="form-group row">
    <label class="control-label col-md-2" for="field_methodsOfIdentification">Methods Of Identification</label>
    <div class="col-md-4">
        <select class="form-control" id="field_methodsOfIdentification" ng-model="orgLabAMR.methodsOfIdentification"
                ng-options="idMethod as idMethod for idMethod in idMethods"/>
    </div>
    <label class="control-label col-md-2" for="field_identificationDetails">Identification Details</label>
    <div class="col-md-4">
        <input type="text" class="form-control" name="identificationDetails" id="field_identificationDetails"
               ng-model="orgLabAMR.identificationDetails"
        />
    </div>
</div>
<div class="form-group row">
    <label class="control-label col-md-2" for="field_standardSusceptibilityTestingMethod">Standard Susceptibility
        Testing Method</label>
    <div class="col-md-4">
       <select class="form-control" id="field_standardSusceptibilityTestingMethod" ng-model="orgLabAMR.standardSusceptibilityTestingMethod"
                ng-options="standardSuscTestMethod as standardSuscTestMethod for standardSuscTestMethod in standardSuscTestMethods"/>
    </div>

    <label class="control-label col-md-2" for="field_molecularSusceptibilityTestingMethod">Molecular Susceptibility
        Testing Method</label>
    <div class="col-md-4">
        <select class="form-control" id="field_molecularSusceptibilityTestingMethod" ng-model="orgLabAMR.molecularSusceptibilityTestingMethod"
                ng-options="molecularSuscep as molecularSuscep for molecularSuscep in molecularSusceps"/>
    </div>
</div>

<div class="form-group row">
    <label class="control-label col-md-2" for="field_automatisedSusceptibilityTestingMethod">Automatised Susceptibility
        Testing Method</label>
    <div class="col-md-4">
        <select class="form-control" id="field_automatisedSusceptibilityTestingMethod" ng-model="orgLabAMR.automatisedSusceptibilityTestingMethod"
                ng-options="automaSusceTestMethod as automaSusceTestMethod for automaSusceTestMethod in automaSusceTestMethods"/>
    </div>
    <label class="control-label col-md-2" for="field_susceptibilityTestingMethodsDetails">Susceptibility Testing Methods
        Details</label>
    <div class="col-md-4">
        <input type="text" class="form-control" name="susceptibilityTestingMethodsDetails"
               id="field_susceptibilityTestingMethodsDetails"
               ng-model="orgLabAMR.susceptibilityTestingMethodsDetails"
        />
    </div>
</div>
<div class="form-group row">
    <label class="control-label col-md-2" for="field_susceptibilityMethodsComments">Susceptibility Methods
        Comments</label>
    <div class="col-md-10">
        <input type="text" class="form-control" name="susceptibilityMethodsComments"
               id="field_susceptibilityMethodsComments"
               ng-model="orgLabAMR.susceptibilityMethodsComments"
        />
    </div>
</div>


<button class="btn btn-danger margin10" ng-click="removeOrganismLaboratoryAMR(study, orgLabAMR)">remove Organism
    Laboratory {{orgLabAMR.id}}
</button>

在 localhost 中加载它时,它显示所有元素都很好,如下所示:

但在生产环境中加载时,它不会解析所有元素,它会显示如下:

现在有趣的是,我有几个模板,就像其他实体一样,它们都可以很好地加载它们的元素。

在浏览器中查找元素时,它不会在代码 sn-ps 中显示它们,尽管在 jenkins 工作区中检查时,html 文件与本地版本中的完全相同。

【问题讨论】:

  • 您的“有机体”输入字段缺少结束符“/”。你的html文件被缓存了吗?尝试通过右键单击 Chrome 中的刷新图标并选择“清空缓存并硬重新加载”来重新加载文件(这仅适用于打开 F12 的开发者控制台)。
  • 感谢您的评论,我通过添加关闭“/”更新代码并部署,按照您建议的方式清空缓存,但它不起作用,也用 Ctrl + Upper + Del 清空,但没有改变任何一个
  • 这取决于你的 JHipster 版本,但通常你有 Gulp 来缩小你的源代码,并生成一个源映射(这样你就可以调试你的产品代码)。您可以查看调试产品代码,如果该 HTML 真的丢失,那么当 Gulp 进行缩小时这是一个问题 -> 取决于 Gulp 版本、缩小过程以及您的代码
  • 嗨 Julien,感谢您的评论,是的,我已经使用 prod 配置文件在本地调试了代码,并且 HTML 在那里,视图看起来不错。此错误只会重现在服务器 (VM) 上运行的自身。来自 VM tomcat webapps 文件夹的战争中缩小的 gulp 文件显示了所有 HTML 元素,但是在检查调试器工具时它们不存在。我希望我是有道理的......
  • 找到解决方案,请检查答案,非常欢迎任何关于为什么会发生这种情况的知识

标签: angularjs html tomcat jenkins gulp


【解决方案1】:

在尝试使用 prod 配置文件本地调试并检查由 gulp 生成的所有缩小文件并找到其中的所有 html 元素后,我决定专注于标记,魔术来自将可自动关闭的 &lt;select /&gt; 标签更改为 @987654324 @标签

现在视图完美呈现,但我仍然很困惑为什么这只会在生产时发生,因为浏览器完全相同。

【讨论】:

  • Angular 1 为许多 HTML 标签提供了指令,也许 &lt;select&gt; 不喜欢空选择。我猜 Angular 2 不会发生这种情况,因为模板会被编译。
  • 有道理,我们总是在 angular 中遇到很多关于`
猜你喜欢
  • 2016-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-16
相关资源
最近更新 更多