小编eme*_*ava的帖子

twitter bootstrap typeahead ajax示例

我试图找到一个twitter bootstrap typeahead元素的工作示例,该元素将进行ajax调用以填充它的下拉列表.

我有一个现有的工作jquery自动完成示例,它定义了ajax url以及如何处理回复

<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
    var options = { minChars:3, max:20 };
    $("#runnerquery").autocomplete('./index/runnerfilter/format/html',options).result(
            function(event, data, formatted)
                {
                    window.location = "./runner/index/id/"+data[1];
                }
            );
       ..
Run Code Online (Sandbox Code Playgroud)

我需要更改什么来将其转换为typeahead示例?

<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
    var options = { source:'/index/runnerfilter/format/html', items:5 };
    $("#runnerquery").typeahead(options).result(
            function(event, data, formatted)
                {
                    window.location = "./runner/index/id/"+data[1];
                }
            );
       ..
Run Code Online (Sandbox Code Playgroud)

我将等待" 添加远程源支持预先输入 "问题得到解决.

jquery jquery-autocomplete jquery-ui-autocomplete twitter-bootstrap typeahead.js

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

Eclipse Junit'-ea'VM选项

在eclipse偏好中

Windows > Preferences > Java > Junit
Run Code Online (Sandbox Code Playgroud)

替代文字

"添加'-ea'到VM args ...."复选框选项实际上对新的junit启动配置有什么影响?

eclipse ide junit

48
推荐指数
1
解决办法
3万
查看次数

没有数据源的spring-boot应用程序

是否可以创建一个没有数据源的spring-boot应用程序?在我的情况下,我只需要一个简单的REST应用程序,但似乎在启动时尝试自动初始化数据源

我的pom.xml是

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>a.b.c.d.test</groupId>
    <artifactId>rest-customer-builder</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>rest-customer-builder</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.5.RELEASE</version>
        <!--<relativePath/> lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.7</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

我的application.properties是

server.contextPath=/rest-customer-builder
server.port=9090
Run Code Online (Sandbox Code Playgroud)

当我跑

mvn clean install spring-boot:run
Run Code Online (Sandbox Code Playgroud)

我看到这个错误

015-08-18 14:54:31.870  INFO 12530 --- [lication.main()] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2015-08-18 14:54:31.903  WARN …
Run Code Online (Sandbox Code Playgroud)

spring-boot

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

Jboss Java EE容器和ExecutorService

我有一个独立的Java应用程序,它使用ExecutorService并行处理大量作业

 ExecutorService es = Executors.newFixedThreadPool(10);
Run Code Online (Sandbox Code Playgroud)

我现在想在EJB bean中重用相同的解决方案但不确定如何正确初始化ThreadPool,因为我通常会让Java EE容器控制所有线程资源.我可以使用相同的代码,还是有另一种正确的方法来获取Jboss托管线程池?

java concurrency jboss multithreading ejb

27
推荐指数
3
解决办法
3万
查看次数

Java枚举:重构switch语句的常量表达式需要'编译错误?

我有一个类为我的应用程序声明常量

public class GroupConstants {
    ..
    public static final int INTEGER_VALUE = 1;
    public static final int LONG_VALUE = 2;
    public static final int STRING_VALUE = 3;
    ..
}
Run Code Online (Sandbox Code Playgroud)

在代码中有一组switch语句

private static Object getValue(String stringValue, Parameter parameter) throws InvalidPatternException
{
    Object result=null;
    switch (parameter.getDataType())
    {
        case GroupConstants.STRING_VALUE: // String value
            result=stringValue;
        break;
        case GroupConstants.INTEGER_VALUE: // Long value
        case GroupConstants.LONG_VALUE:
        case GroupConstants.BOOLEAN_VALUE:
        case GroupConstants.DATE_VALUE:
..
}
Run Code Online (Sandbox Code Playgroud)

我想重构int常量值以由枚举表示

public enum DataType {

    UNKNOWN_VALUE(0,"unknown"),
    INTEGER_VALUE(1,"integer"),
    LONG_VALUE(2,"long"),
    STRING_VALUE(3,"string"),
    BOOLEAN_VALUE(4,"boolean"),
..
}
Run Code Online (Sandbox Code Playgroud)

所以我的代码可能看起来像这样

@Deprecated
public …
Run Code Online (Sandbox Code Playgroud)

java

17
推荐指数
3
解决办法
3万
查看次数

Spring框架:使用util:map填充Map <Enum,Object>

我有这个工厂类,我想通过spring连接到地图的运行时配置.该映射包含枚举对象和标准pojo.

public class GenericEntityFactoryImpl implements GenericEntityFactory
{
    private Map<IndexType,IEntity> indexEntityMap = null;

    @Override
    public IEntity getIndexEntity(IndexType index) {
        return indexEntityMap.get(index);
    }

    public Map<IndexType, IEntity> getIndexEntityMap() {
        return indexEntityMap;
    }

    public void setIndexEntityMap(Map<IndexType, IEntity> indexEntityMap) {
        this.indexEntityMap = indexEntityMap;
    }
}
Run Code Online (Sandbox Code Playgroud)

我在使用spring util时出现问题:地图布线,因为在确定键值时我不确定如何正确引用特定的枚举类型.地图值的bean ref很简单.弹簧图布线的所有例子似乎都假设键是一个字符串!

<!-- the value object bean -->
<bean id="cell" class="com.xx.xx.common.index.entity.CellEntity"/>

<bean id="genericEntityFactory" class="com.xx.xx.common.index.GenericEntityFactoryImpl">
  <util:map 
       id="indexEntityMap" 
       map-class="java.util.HashMap" 
       key-type="com.xx.xx.common.index.IndexType" 
       value-type="com.xx.xx.common.index.GenericEntityFactoryImpl">
           <entry key="CELL">
                <ref bean="cell"/>
            </entry>
       </util:map>
</bean> 
Run Code Online (Sandbox Code Playgroud)

编辑

所以我重构了映射

<bean id="genericEntityFactory" class="com.xx.xx.common.index.GenericEntityFactoryImpl" >
    <property name="indexEntityMap">
        <map >
            <entry key="com.xx.xx.common.index.CELL"><ref bean="cell"/></entry> …
Run Code Online (Sandbox Code Playgroud)

java spring

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

Zend Form Validator:元素A或元素B.

我的Zend表单中有两个字段,我想应用验证规则,确保用户输入这两个字段中的任何一个.

    $companyname = new Zend_Form_Element_Text('companyname');
    $companyname->setLabel('Company Name');
    $companyname->setDecorators($decors);
    $this->addElement($companyname);

    $companyother = new Zend_Form_Element_Text('companyother');
    $companyother->setLabel('Company Other');
    $companyother->setDecorators($decors);
    $this->addElement($companyother);
Run Code Online (Sandbox Code Playgroud)

如何添加一个可以查看这两个字段的验证器?

zend-framework zend-form zend-form-element

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

JAXB文档注释

我有以下带有JAXB @XMLRootElement注释的java类

@XmlRootElement(name="ClientData")
public class ClientData {

/**
 * The first address field of the person
 */
private String address1 = null;
}
Run Code Online (Sandbox Code Playgroud)

当我生成xsd模式时,它会生成这个xml片段

<xs:complexType name="clientData">
  <xs:sequence>
   <xs:element minOccurs="0" name="address1" type="xs:string"/>
Run Code Online (Sandbox Code Playgroud)

是否可以使用JAXB注释,以便在我的最终模式中将address1字段的文档详细信息包含为xs:annotation/xs:documentention元素?

<xs:complexType name="clientData">
  <xs:sequence>
   <xs:element minOccurs="0" name="address1" type="xs:string">
    <xs:annotation>
      <xs:documentation>The first address field of the person</xs:documentation>
    </xs:annotation>
   </xs:element>
Run Code Online (Sandbox Code Playgroud)

java xsd jaxb

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

Zend和.htaccess

我的默认'zend'应用程序具有此默认结构

/zend + webroot
    /application
    /config
    /library
    /public
        .htaccess
        index.php
Run Code Online (Sandbox Code Playgroud)

默认.htaccess通过./public/index.php重定向各种控制器/操作详细信息

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Run Code Online (Sandbox Code Playgroud)

我使用此默认网址来访问该应用

http://domain/index.php
Run Code Online (Sandbox Code Playgroud)

我现在已经转移到共享主机,其中webroot位于'zend'根目录之上.

/webroot
    /zend
        /application
        /config
        /public
            index.php
           .htaccess
Run Code Online (Sandbox Code Playgroud)

但我只能通过此URL访问我的应用程序

http://domain/zend/public/index.php
Run Code Online (Sandbox Code Playgroud)

我希望能够使用

http://domain/zend/index.php
Run Code Online (Sandbox Code Playgroud)

并有.htaccess重定向.

我想知道如何调整.htaccess文件来重定向URL请求.我读了这个教程,但我没有为我工作

/webroot
    /zend
        .htaccess
        /application
        /config
        /library
        /public
            index.php
Run Code Online (Sandbox Code Playgroud)

在这种情况下,这是.htaccess内容

RewriteEngine On

RewriteRule ^\.htaccess$ - [F]

RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} …
Run Code Online (Sandbox Code Playgroud)

apache .htaccess zend-framework

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

PDFBox设置A5页面大小

开始玩PDFBox了

PDDocument document = new PDDocument();
PDPage page = new PDPage();
document.addPage( page );

PDFont font = PDType1Font.HELVETICA_BOLD;
PDPageContentStream contentStream = new PDPageContentStream(document, page);
contentStream.beginText();
contentStream.setFont( font, 12 );
contentStream.moveTextPositionByAmount( 100, 700 );
contentStream.drawString( "Hello World" );
contentStream.endText();
contentStream.close();

document.save("Page.pdf");
document.close();
Run Code Online (Sandbox Code Playgroud)

但我想将文件大小设置为PDPage.PAGE_SIZE_A5.我已经尝试设置所有setXXXBox(PDRectangle mediaBox)方法签名但我无法获得预期的输出.

page.setArtBox(PDPage.PAGE_SIZE_A5); // ??
page.setMediaBox(PDPage.PAGE_SIZE_A5); // ??
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

java pdf pdfbox apache-fop

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