小编svj*_*vjn的帖子

form.submit()无法在Firefox中运行

我正在使用以下javascript函数来构造表单并将其提交给服务器.它在Chrome浏览器中运行良好,但在Firefox中无效.

function loadPage(url, projectName){
    var jForm = $('<form></form>');
    jForm.attr('action', url);
    jForm.attr('method', 'post');

    var jInput = $("<input>");
    jInput.attr('name', 'curPrj');
    jInput.attr('value', projectName);
    jForm.append(jInput);

    jForm.submit();
}
Run Code Online (Sandbox Code Playgroud)

我从SE的旧帖子Mozilla form.submit()中找不到任何建议,将表单附加到文档正文document.body.appendChild(jForm)但不幸的是,这对我也没有用.我document.body.appendChild(jForm)在表单提交之前使用时在调试控制台中出现以下错误.

TypeError: Argument 1 of Node.appendChild does not implement interface Node. @ http://localhost:9000/assets/javascripts/global.js
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么吗?请指教.

html javascript forms jquery

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

Durandal JS:输入没有哈希的URL给出HTTP错误404.0 - 未找到

我正在使用Durandaljs构建SPA应用程序.当我输入一个没有哈希的URL时,它显示错误:HTTP error 404.0 - NOT FOUND.但是,它正常工作与哈希.

例:

www.domain.com/page =>  HTTP error 404.0 - NOT FOUND
www.domain.com/#page = > working fine.
Run Code Online (Sandbox Code Playgroud)

我该如何映射www.domain.com/pagewww.domain.com/#page

hash http-status-code-404 durandal

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

spring-data-redis redisTemplate Exception

当我调用get()方法时,发生了异常

这是代码

@Service("RedisService")
public class RedisServiceImpl implements RedisService {

@Autowired
RedisTemplate<String, Long> redisTemplate;

@Override
public Long get(String key) {
    return redisTemplate.opsForValue().get(key);
}

@Override
public Long incrBy(String key, long increment) {
    return redisTemplate.opsForValue().increment(key, increment);
}
Run Code Online (Sandbox Code Playgroud)

当我使用incrBy方法时,没有例外但只有错误只有get方法





在这里才是栈跟踪---

java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
    at org.springframework.core.serializer.DefaultDeserializer.deserialize(DefaultDeserializer.java:38)
    at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:58)
    at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:1)
    at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.deserialize(JdkSerializationRedisSerializer.java:40)
    at org.springframework.data.redis.core.AbstractOperations.deserializeValue(AbstractOperations.java:198)
    at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:50)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:162)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:133)
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:84)
    at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:42)
    at net.daum.air21.bot.common.service.RedisServiceImpl.get(RedisServiceImpl.java:29)
    at net.daum.air21.bot.user.service.SeraCoffeeServiceImpl.getCurrentCount(SeraCoffeeServiceImpl.java:41)
Run Code Online (Sandbox Code Playgroud)

spring redis jedis spring-data-redis

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

如何避免play框架中的延迟加载

在游戏框架中,我使用以下代码从名为“Report”的表中获取值,该表具有其他关系表,如“Project”、“Build”等。

List<Report> rpts = Report.find.where()
                            .eq("publish","1")
                            .eq("functionality_id", Integer.toString(fun.id))
                            .eq("project_id", currentProject.id)
                            .eq("prod_build", prod_build)
                            .eq("loadType_id", loadType_id)
                            .in("build_id", buildId)                            
                            .orderBy("id desc")                                             
                            .findList();
Run Code Online (Sandbox Code Playgroud)

我从“报告”表中获取值列表,但未填充所有相关表值。它们填充有 null。

@Entity
@Table(name="report")
public class Report {

    @Id
    public int id;

    @Constraints.Required
    @ManyToOne
    @JoinColumn(name="build_id")
    public Build build;

@Constraints.Required
    @ManyToOne
    @JoinColumn(name="project_id")
    public Project project;
.
.
}
Run Code Online (Sandbox Code Playgroud)

当我几天前测试时,它加载了这些值,但今天不起作用。当我这样做时rpts.get(i).build.release,它会给出nullPointerException,因为构建在这里为空。该代码最近几天没有更改。想知道为什么会发生这种情况。有人可以建议我是否有任何其他设置文件(如 application.conf)可以执行此延迟加载。请帮忙。

jpa playframework ebean

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

如何获取声纳REST api中的所有心室指标值

我能够使用以下java代码从声纳REST API获取项目(资源)列表

Sonar sonar = Sonar.create("wwww.example.com/sonar/api/resources?metrics=nloc");
ResourceQuery query = new ResourceQuery();
List resourceList = sonar.findAll(query);
for(Resource resource : resourceList){
  System.out.println(resource.getid()+":"+resource.getMetricIntValue("nloc"));
}
Run Code Online (Sandbox Code Playgroud)

但这导致了

1001:null
1002:null
1003:null
1004:null
Run Code Online (Sandbox Code Playgroud)

为什么代码行的值返回null?

rest web-services sonarqube

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

Elasticsearch观察者电子邮件数组值

我正在研究ELK观察者创建一个警报,该警报发送使用'transform'映射转换的值数组.

"transform": {
   "script": "return [ err_yest : ctx.payload.aggregations.errorcount.buckets.collect { [err_count:it.doc_count, list_errors: it.errs.buckets.collect{[emsg:it.key,emsc:it.doc_count]}] } ]"
 },
Run Code Online (Sandbox Code Playgroud)

有没有办法使用任何循环方法在电子邮件警报正文中打印数组值?我尝试了groovy脚本,但得到一个错误,说它不受支持.我所能做的就是手动打印数组中的值,如下所示.

"body" : {
          "html": "<table width='400px' border='1'><thead><tr><th colspan='4'>Error Messages</th></tr><tr><th colspan='2'>Yesterday</th><th colspan='2'>Today</th></tr></thead><tbody><tr><td>{{ctx.payload.err_yest.0.list_errors.0.emsc}}</td><td align='center'>{{ctx.payload.err_yest.0.list_errors.0.emsg}}</td><td>{{ctx.payload.err_yest.1.list_errors.0.emsc}}</td><td align='center'>{{ctx.payload.err_yest.1.list_errors.0.emsg}}</td></tr><tr><td>{{ctx.payload.err_yest.0.list_errors.1.emsc}}</td><td align='center'>{{ctx.payload.err_yest.0.list_errors.1.emsg}}</td><td>{{ctx.payload.err_yest.1.list_errors.1.emsc}}</td><td align='center'>{{ctx.payload.err_yest.1.list_errors.1.emsg}}</td></tr><tr><td>{{ctx.payload.err_yest.0.list_errors.2.emsc}}</td><td align='center'>{{ctx.payload.err_yest.0.list_errors.2.emsg}}</td><td>{{ctx.payload.err_yest.1.list_errors.2.emsc}}</td><td align='center'>{{ctx.payload.err_yest.1.list_errors.2.emsg}}</td></tr></tbody></table>"
        },
Run Code Online (Sandbox Code Playgroud)

arrays groovy elasticsearch elasticsearch-watcher

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

Spring Boot 与 Logback + springProperty

我已经按照Spring Boot Documentation配置了 logback-spring.xml 。这是我的 logback-spring.xml 文件

<configuration>

    <springProperty name="appName" source="spring.application.name" defaultValue="myLogFile" />

    <property name="log.date" value="%d{yyyy-MM-dd}" />
    <property name="log.path" value="/log" />
    <property name="log.file" value="${appName}" />
    <property name="log.live.path" value="${log.path}/${log.file}.log" />

    <appender name="myLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.live.path}</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/archive/${log.file}.${log.date}.log.gz</fileNamePattern>
            <maxHistory>1</maxHistory>
        </rollingPolicy>
    </appender>

    <logger name="com.log.logback" level="INFO" />
    <logger name="com.log.sample" level="INFO" />

    <root level="ERROR">
        <appender-ref ref="myLogAppender" />
    </root>
</configuration>
Run Code Online (Sandbox Code Playgroud)

应用程序属性

spring.application.name=mybootapp
Run Code Online (Sandbox Code Playgroud)

当我启动 Spring Boot 应用程序时,我看到在/log路径下创建了 2 个目录,分别是myLogFilebootstrap。从日志中,我可以看到 bootstrap 目录是在 logback 访问 spring 属性之前创建的。我不知道为什么创建引导目录。<springProperty>在logback xml中使用之前我没有看到这个问题。我这里缺少任何配置吗?我在网上找不到任何相关信息。 …

spring logback slf4j spring-boot

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

SQL错误:1054,SQLState:42S22

大家好我正试图从我的数据库中检索一些数据,但我得到了

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'subject_id' in 'where clause'
Run Code Online (Sandbox Code Playgroud)

如果我检索同一个表的其他列,它可以工作.我正在使用spring和hibernate

这是我的控制器代码

@RequestMapping(value = "/getAnyQuestion", method = RequestMethod.GET)
public @ResponseBody
String getAnyQuestion(
        @RequestParam(value = "subId", required = true) Long subId,
        @RequestParam(value = "questionType", required = true) String questionType) {

    Question questionList = questionService.getAnyQuestion(subId,questionType);

    if (questionList != null) {
        questionId = questionList.getId();
        return questionList.getQuestionText();
    }

    return "";
}
Run Code Online (Sandbox Code Playgroud)

这是我的服务

 public Question getAnyQuestion(Long subId,String questionType) {             
    String query = "subject_id = " + subId +"  and "+ "questionType='" + questionType +"' and 1=1 order …
Run Code Online (Sandbox Code Playgroud)

mysql hibernate spring-mvc

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

org.hibernate.HibernateException:无法获取当前线程的事务同步会话

我试图使用hibernate 4创建一个简单的spring mvc应用程序.我在这里包含了我的配置和相应的dao,service和controller类.当我访问控制器时,我收到错误,我无法弄清楚问题的来源.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <context:annotation-config />
    <context:component-scan base-package="com.test" />
    <import resource="security-context.xml"/>

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/test" />
        <property name="username" value="root" />
        <property name="password" value="123" />
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="com.test.model" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
    </bean>

    <tx:annotation-driven/>
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

</beans>
Run Code Online (Sandbox Code Playgroud)

这是我的服务层

@Service
@Transactional …
Run Code Online (Sandbox Code Playgroud)

hibernate transactions spring-mvc

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

调整图片大小vc ++

是否有任何功能可以快速调整Visual C++中的图片大小?我想制作一张原始图片的副本,它会小x倍.然后我想把它放在黑色位图的中心.黑色位图的大小与第一张图片的大小相同.

这是原始图片:https://www.dropbox.com/s/6she1kvcby53qgz/term.bmp

这是我想要收到的效果:https: //www.dropbox.com/s/8ah59z0ip6tq4wd/term2.bmp

在我的程序中,我使用Pylon的库.图像采用CPylonImage类型.

c++ pylons visual-c++ image-resizing

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