小编kam*_*lot的帖子

Tomcat 8 URL重写

我有一个AngularJS webapp和Jersey后端.我需要设置URL重写,因此除了给定的异常之外的所有内容都将被重写为Angular的index.html.

例如.:

http://my.domain.com/about will be rewritten
http://my.domain.com/photos/photo1.jpg will NOT be rewritten (file photo 1 exists)
http://my.domain.com/rest/myservice will be NOT be rewritten (it is a call to REST service)
Run Code Online (Sandbox Code Playgroud)

我已经设置了Tomcat 8 URL重写阀,如下所示:

在conf/server.xml中

<Host name="my.domain.com" appBase="webapps/MyDomainServer" unpackWARs="true"
           autoDeploy="true"
           xmlValidation="false" xmlNamespaceAware="false">
  <Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
  <!-- access logging, aliases,...-->
</Host>
Run Code Online (Sandbox Code Playgroud)

在conf/Catalina/my.domain.com/rewrite.config中

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} ^/rest.*
RewriteRule ^ - [L]

RewriteRule ^ index.html [L]
Run Code Online (Sandbox Code Playgroud)

Tomcat忽略了我的重写设置,没有重写,日志中没有错误/异常.我究竟做错了什么?提前致谢.

我试图将RewriteValve移动到META-INF中的config.xml并将配置重写为WEB-INF,但它的行为方式相同.

java apache url-rewriting angularjs tomcat8

13
推荐指数
2
解决办法
2万
查看次数

AngularJS:截断ng-repeat/ng-bind-html中绑定的多行HTML

我有以下ng-repeat

<div class="item-post" ng-repeat="item in items">
    <div class="item-content" ng-bind-html="item.text"></div>
</div> 
Run Code Online (Sandbox Code Playgroud)

其中item.text是多行HTML文本,它正确显示,但我需要将其截断为item-post div(250px)的max-height.然后附加三个点,表示文本更长.

我想使用jquery.autoellipsis,例如div静态内容.

对于AngularJS,我发现了角度省略号,但不适用于HTML,只能使用纯文本.我需要在HTML内容上实现它.

在此先感谢您的帮助!

编辑/解决方案:

最后,我已经能够使用自定义指令使用jquery.autoellipsis插件(基于asgoth的答案):

myDirectives.directive('htmlEllipsis', ['$timeout', function($timeout) {
        return {
            restrict: 'A',
            link: function(scope, element, attrs) {
                $timeout(function() {
                    angular.element(element).ellipsis();
                }, 0);

            }
        };
    }]);
Run Code Online (Sandbox Code Playgroud)

在局部视图中:

<div class="item-post" ng-repeat="item in items">
    <div class="item-content" ng-bind-html="item.text" html-ellipsis></div>
</div> 
Run Code Online (Sandbox Code Playgroud)

EDIT2:

在他的编辑工作得很好之后asgoth的回答指令,使用了另一种方法而不是上述指令.

html javascript truncate ellipsis angularjs

2
推荐指数
1
解决办法
9219
查看次数

使用POJO和String值自动完成Primefaces

我需要具有带有字符串值的自动填充功能,因为不能通过自动填充方法将用户限制为提供的项目,但是他们应该能够在搜索字段中写入任何内容。如果他们愿意,他们也可以从建议中选择。

现在,我总是得到 /archive/overview.xhtml @ 28,57 itemLabel =“#{item.name}”:类'java.lang.String'没有属性'name'。

XHTML:

<p:autoComplete id="vyraz" value="#{archiveView.searchString}"
  completeMethod="#{archiveView.autocomplete}"
  var="item" itemLabel="#{item.name}" itemValue="#{item.name}"
  converter="archiveConverter" forceSelection="false" minQueryLength="2"
  autoHighlight="false" effect="fade">

  <p:column>
    <h:outputText value="#{item.name}"/>
    <h:outputText value=" (Barcode: #{item.barcode})" rendered="#{item.barcode ne null}"/>
  </p:column>

  <p:column>
   <h:outputText value="#{item.type.label}" style="font-weight: bold;"/>
  </p:column>
</p:autoComplete>
Run Code Online (Sandbox Code Playgroud)

豆:

private String searchString; // + getter and setter

public List<ArchiveAutoCompleteDto> autocomplete(String query) {
    // get and return from lucene index/database
}
Run Code Online (Sandbox Code Playgroud)

有没有办法实现这一点(Primefaces 5.2)?
谢谢!

jsf autocomplete converter primefaces jsf-2

2
推荐指数
1
解决办法
5200
查看次数