小编Pra*_*kar的帖子

AngularUI-Bootstrap Typeahead:对结果进行分组

我正在使用AngularUI-Bootstrap实现typeahead.我需要根据来自数据库的一些值显示分组结果.这是一个示例场景

  1. 数据库中有一些用户,每个用户都有一个"部门".一个用户名可以在多个部门中使用.
  2. 最终用户键入名称以从数据库中搜索用户并检索预先输入列表中的列表.由于一个用户名可以属于多个部门,因此要求显示按不同部门分组的用户名.像这样的东西: 在此输入图像描述
  3. 然后,用户可以选择所需的用户名并继续.

根据此处提供Typeahead文档,我认为没有任何选项可以满足我的要求.

我尝试过这种解决方法:每当typeahead数组形成时,我都会将用户部门附加到数组元素:

$scope.fetchUsers = function(val) {
        console.log("Entered fetchUsers function");
        return $http.get("http://localhost:8080/TestWeb/users", {
            params : {
                username : val
            }
        }).then(function(res) {
            console.log("Response:",res);
            var users = [];
            angular.forEach(res.data, function(item) {
                users.push(item.UserName + " - " + item.UserDepartment);
            });
            console.log("users=",users);
            return users;
        });
    };
Run Code Online (Sandbox Code Playgroud)

这样,至少最终用户可以看到该部门.但是当我选择记录时,所选值是数组元素的全部内容.以下是详细说明的示例截图:

HTML

用户来自本地服务
<pre>Model: {{userList | json}}</pre>
<input type="text" ng-model="userList" placeholder="Users loaded from local database" 
typeahead="username for username in fetchUsers($viewValue)" 
typeahead-loading="loadingUsers" class="form-control">
<i ng-show="loadingUsers" class="glyphicon glyphicon-refresh"></i>
Run Code Online (Sandbox Code Playgroud)

用户键入字符串

搜索结果

用户选择一条记录

用户选择一条记录

- Desc …

javascript typeahead twitter-bootstrap angularjs

16
推荐指数
1
解决办法
9364
查看次数

AngularJS-Bootstrap中的错误TypeAhead:TypeError:无法读取未定义的属性"length"

我在尝试从AngularUI-Bootstrap实现AngularJS Typeahead时遇到以下错误:(我只是调用一个以JSON格式返回结果的servlet)

TypeError: Cannot read property 'length' of undefined
    at http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js:3553:24
    at wrappedCallback (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js:10930:81)
    at wrappedCallback (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js:10930:81)
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js:11016:26
    at Scope.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js:11936:28)
    at Scope.$digest (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js:11762:31)
    at Scope.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js:12042:24)
Run Code Online (Sandbox Code Playgroud)

HTML

<h4>Users from local service</h4>
    <pre>Model: {{userList | json}}</pre>
    <input type="text" ng-model="userList" placeholder="Users loaded from local database" 
    typeahead="username for username in fetchUsers($viewValue)" 
    typeahead-loading="loadingUsers" class="form-control">
    <i ng-show="loadingUsers" class="glyphicon glyphicon-refresh"></i>
Run Code Online (Sandbox Code Playgroud)

JS

$scope.fetchUsers = function(val) {
        console.log("Entered fetchUsers function");
        $http.get("http://localhost:8080/TestWeb/users", {
            params : {
                username : val
            }
        }).then(function(res) {
            var users = [];
            angular.forEach(res.data, …
Run Code Online (Sandbox Code Playgroud)

javascript servlets typeahead twitter-bootstrap angularjs

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

IE 11:发送Multipart Form Data请求时出错:Stream意外结束

我正在尝试使用jQuery AJAX调用上传文件和其他一些表单字段.

这是一个调用服务器上URL的常用函数:

function uploadDocument(rquestURL,formId,callback){
        $.ajax({
            type : 'POST',
            url : rquestURL,
            cache:false,
            processData:false,
            contentType:false,
            data : new FormData($("#"+formId)[0])
        }).done(function(response) {
            callback(response);
        });
}
Run Code Online (Sandbox Code Playgroud)

在从浏览器的开发工具中检查时,这些是相应的请求内容:

来自IE11

-----------------------------7dfad39402e6
Content-Disposition: form-data; name="subject"

Test
-----------------------------7dfad39402e6
Content-Disposition: form-data; name="message"

Test test
-----------------------------7dfad39402e6
Content-Disposition: form-data; name="announcementAttachment"; filename=""
Content-Type: application/octet-stream

<Binary File Data Not Shown>
---------------------------7dfad39402e6
Run Code Online (Sandbox Code Playgroud)

------WebKitFormBoundaryp8rj3ArKDsbYw0BZ
Content-Disposition: form-data; name="subject"

Test
------WebKitFormBoundaryp8rj3ArKDsbYw0BZ
Content-Disposition: form-data; name="message"

Test test
------WebKitFormBoundaryp8rj3ArKDsbYw0BZ
Content-Disposition: form-data; name="announcementAttachment"; filename=""
Content-Type: application/octet-stream


------WebKitFormBoundaryp8rj3ArKDsbYw0BZ--
Run Code Online (Sandbox Code Playgroud)

在服务器端,我们将请求解析为:

import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

final FileItemFactory factory = new …
Run Code Online (Sandbox Code Playgroud)

java jquery file-upload multipartform-data internet-explorer-11

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

在Bootstrap面板上调用一个事件展开

我正在开发一个流程,我们正在使用Bootstrap风格的手风琴(不是jQuery UI手风琴).要求是在用户扩展手风琴时调用服务.这是HTML:

<div class="accordion-dashboard">
    <div class="panel-group" id="accordion">
        <div class="panel panel-default">
            <div class="panel-heading  row-white" data-toggle="collapse" data-parent="#accordion" href="#runtimeValue">                 
                <table>
                    <tr>
                        <td><span class="badge blue">A</span></td>
                        <td><strong>Aenean ultricies est lorem,id feugiat velit euismod ut.Nullam inia.Prasent vel nu Sed ante mauris, eu lacus..</strong></td>
                        <td><i class="icon8 icon-paperclip"></i></td>
                        <td><span class="time">5 mins</span></td>
                    </tr>                    
                </table>                        
            </div>
            <div id="runtimeValue" class="panel-collapse collapse ">
                <div class="panel-body">

                    <div class="row">
                        <div class="col-lg-9 col-lg-offset-1">
                            <table>
                                <tr>
                                    <td class="text-muted">By</td>
                                    <td><img width="24px" src="images/company-logo.png"> Company Admin</td>
                                </tr>
                                <tr>
                                    <td class="text-muted">On</td>
                                    <td class="text-muted">Friday- 7 Aug 2014, 9.00PM</td>
                                </tr>
                                <tr>
                                    <td><i …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery twitter-bootstrap

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

如何在Spring AOP中获取HttpServletRequest和HttpServletResponse对象

我想在建议之前在Spring AOP中获取响应对象.如果会话无效,我想重定向到登录页面,但无法在Before advice方法中获取HttpServletResponse对象.

尝试以下方式.

    @Autowired
    private HttpServletResponse response;

    public void setResponse(HttpServletResponse response) {
        this.response = response;
    }
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: javax.servlet.http.HttpServletResponse com.****.****.aspect.LogProvider.response; nested exception is 

org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.servlet.http.HttpServletResponse] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
    ... 33 more
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

spring servlets spring-mvc spring-aop

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

使用xcopy进行并行复制

我需要将多个目录从一个位置复制到另一个位置.因此,将会有多个xcopy声明,一个接一个.

每个文件夹中的文件数量都很大.有没有办法可以xcopy并行运行这些语句?我能想到的一个选项是 - xcopy在一个单独的批处理文件中调用每个选项,并使用@start而不是调用这些批处理文件@call.

还有其他选择吗?

command xcopy dos batch-file

5
推荐指数
1
解决办法
7341
查看次数

使用Spring实现工作流程

我们正在开发基于Spring的基于Web的应用程序,我们需要实现工作流程.这是示例场景的样子:

  • 用户填写注册表.此请求存储在数据库中,并将通知管理员.
  • 管理员将批准此请求,然后才会实际处理此请求并可以进一步处理.
  • 可以有一个或多个管理员需要根据活动类型批准请求.
  • 将为不同角色分配层次结构.
  • 只有管​​理员才能查看批准或拒绝请求的选项.不是每个人.通常,将有用户类型特定的活动.

一种方法是基于数据库条目设计工作流程.可以为每个用户分配一个/多个角色,并且工作流将涉及这些用户.
Spring有什么能满足我的要求吗?我曾经走过这个这个春天文档,但也不能完全理解.

java workflow spring spring-mvc spring-security

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

Maven构建:Tomcat服务器无法启动

我是Maven的新手,并尝试使用Maven设置一个Web项目.我在Eclipse中设置了项目,我使用的是Tomcat 7.0.53.在Maven构建的运行配置中,我已经设置tomcat:runGoals.
当我运行此配置时,在Eclipse控制台中可以看到以下日志:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Chat sample using the Spring MVC Servlet-based async support 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) > compile @ spring-mvc-chat >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ spring-mvc-chat ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ spring-mvc-chat ---
[INFO] Nothing to compile - all classes are up to date …
Run Code Online (Sandbox Code Playgroud)

java eclipse tomcat maven

4
推荐指数
1
解决办法
5296
查看次数

在表中仅显示有限数量的行

我试图限制显示的行数<table>.我需要在所提取的任何数量的记录中仅显示2行.桌子末端有一个小按钮,点击该按钮可以显示其余记录.

以下是表格外观的示例截图. 在此输入图像描述

我试过搜索SO和其他网站,但无法通过.我也不能在表中使用任何jQuery插件.

如何使用jQuery/JavaScript实现这一目标?

javascript jquery

4
推荐指数
1
解决办法
5415
查看次数

Angular nvd3 LineChart上的黑色背景

我正在尝试使用angular-nvd3库实现角度D3折线图。我们正在使用AngularJS 1.6ES6。这是angular-nvd3的连接方式:

app.js

import angularnvd3 from '../node_modules/angular-nvd3/index';
export default angular.module('myApp', othermodules,..angularnvd3)
.
.
Run Code Online (Sandbox Code Playgroud)

controller.js

this.linechartOptions = {
    chart: {
      type: 'lineChart',
      height: 300,
      width:500,
      x: function(d){ return d.x },
      y: function(d){ return d.y },
      useInteractiveGuideline: true,
      xAxis: {
          axisLabel: 'X Label'
      },
      yAxis: {
          axisLabel: 'Y Label',
      },
    },
    title: {
      enable: true,
      text: 'Some text',
      css: {
        'font-size' : '15px',
        'font-weight' : 'bold',
        'text-align' : 'left'
      }
    },
};

this.linechartData = [{
    values: lineChartData,
    key: …
Run Code Online (Sandbox Code Playgroud)

css linechart d3.js nvd3.js

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

JSP错误"非法启动类型"

我正在尝试运行一个运行HTML-Form的JSP文件,但是我遇到了以下问题:当我尝试在testserver上运行此文件(使用LiveLink运行)时,会出现一个错误,说:


500 Servlet Exception

/WebApps_e/WebApps/FORMS/Formular_Softwareantrag/PDFTest/PDFTest.jsp:34:
illegal start of type

    try
    ^
f:\wcm\website\WEB-INF\work\_jsp\_webapps_0e\_webapps\_forms\_formular_0softwareantrag\_pdftest\_pdftest__jsp.java:319:

<identifier> expected
  private java.util.ArrayList _caucho_depends = new java.util.ArrayList();
                                                                         ^

2 errors
Run Code Online (Sandbox Code Playgroud)

这就是我的JSP-File的样子

<%@ page import="
java.util.*,
java.util.HashMap,
java.net.URL,
java.io.*,
javax.mail.*,
javax.mail.internet.*,
javax.activation.*,
de.gauss.vip.portalmanager.VipObjectBean,
de.gauss.vip.repository.RepositoryEntry,
de.gauss.lang.StringValue,
de.gauss.vip.api.admin.Server,
com.lowagie.text.*,
com.lowagie.text.pdf.*,
com.caucho.vfs.*
" %>
<%!
HashMap pdfOutputs = new HashMap();
Document document = null;
PdfReader reader = null;
PdfStamper stamper = null;
AcroFields acro_fields = null;
ByteArrayOutputStream bostream = null;

try
{
    vobFORMS.setRepositoryName("{VIPDEPLOYMENT_NAME}");
    vobFORMS.addDefaultAttribute("pathname");

    /** Check for standart attributes */
    String …
Run Code Online (Sandbox Code Playgroud)

java jsp servlets

0
推荐指数
1
解决办法
744
查看次数

使用 Apache POI 编写包含 60 多列的大型 Excel 工作表

我正在尝试使用从数据库获取的数据创建多个 Excel 工作表。每个 Excel 工作表包含 60 多个列和大约 50k 条记录(可能有所不同)。问题是系统花费了很多时间(5 分钟以上),然后出现java.lang.OutOfMemoryError: GC overhead limit exceeded异常。

我尝试将列数减少到仅 6 个,周转时间有了巨大的改善。

下面是生成 Excel 工作表字节数组的代码:

int rowIndex = 0;
while (iterator.hasNext()) {
        List<CustomCellDataBean> cellData = iterator.next();

        // Insert generic data
        Row dataContentRow = sheet.createRow((short) rowIndex);

        for (int counter = 0; counter < cellData.size(); counter++) {
            CustomCellDataBean cd = cellData.get(counter);
            if (cd.getValue() != null) {
            // switch case based on the datatype of the cell
                switch (cd.getType()) {
                }
            }
        }
        rowIndex++;
}
// …
Run Code Online (Sandbox Code Playgroud)

java excel apache-poi

0
推荐指数
1
解决办法
8669
查看次数

Javascript正则表达式检查字符串是否是某个字符的组合

我要检查,如果字符串从开始-hypen其次是3个字符的任意组合,即a,pm.

例如:-a , -p , -ap,-am,-apm

请帮忙.

javascript regex jquery

-3
推荐指数
1
解决办法
42
查看次数