小编tdu*_*eau的帖子

查看Spring启动的嵌入式H2数据库的内容

由于以下配置,我想在Web浏览器中查看Spring启动的H2数据库的内容:

<jdbc:embedded-database id="dataSource" type="H2" />

<jdbc:initialize-database data-source="dataSource">
    <jdbc:script location="classpath:db/populateDB.sql"/>
</jdbc:initialize-database>
Run Code Online (Sandbox Code Playgroud)

我在日志中搜索了JDBC URL:

DEBUG o.s.j.d.SimpleDriverDataSource - Creating new JDBC Driver Connection to [jdbc:h2:mem:dataSource;DB_CLOSE_DELAY=-1]
Run Code Online (Sandbox Code Playgroud)

所以我可以填写连接表格如下:

在此输入图像描述

但不幸的是,db仍然是空的,而不应该是由于populateDB.sql脚本.

任何的想法?

谢谢!

spring h2

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

Javascript与Bootstrap崩溃插件切换

我尝试以编程方式使用Bootstrap崩溃插件的切换功能.当我点击手风琴标题中的链接时,我设法切换div,但它只能运行一次,也就是说我无法再次点击隐藏div.

这是我的代码:

<div id="accordion" class="accordion">
    <div class="accordion-group">
        <div class="accordion-heading">
            <a id="program${bean.id}" data-parent="#accordion" 
                   class="accordion-toggle">
            ...
            </a>
        </div>
        <div id="collapse${bean.id}" class="accordion-body collapse">
            <div class="accordion-inner">
            ...
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

后来在JSP中:

$.each($('#accordion a.accordion-toggle'), function(i, link){
    $(link).on('click', 
        function(){
            // ...
            $('#collapse' + id_of_a_bean).collapse({
                toggle : true,
                parent : '#accordion'
            });
            // ...
        }
    )
});
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

toggle collapse twitter-bootstrap

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

将Jsonpath输出映射到POJO列表

我正在尝试将Jsonpath的输出直接映射到POJO列表.我正在使用杰克逊作为地图提供商.

Jsonpath输出:

{
  "actions" : [
    {
      "parameterDefinitions" : [
        {
          "defaultParameterValue" : {
            "name" : "PARAM1",
            "value" : ""
          },
          "description" : "Type String",
          "name" : "PARAM1",
          "type" : "StringParameterDefinition"
        },
        {
          "defaultParameterValue" : {
            "name" : "PARAM3",
            "value" : ""
          },
          "description" : "Type String",
          "name" : "PARAM3",
          "type" : "StringParameterDefinition"
        }
      ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

JobParameter.java(我要映射的POJO):

public class JobParameter {

   private String description;
   private String name;
   private String type;

   // public getters & setters
Run Code Online (Sandbox Code Playgroud)

Jsonpath初始化 …

java jsonpath jackson

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

如何从html页面到spring mvc控制器获取选中的复选框值

我使用带有 thymeleaf 模板引擎的 spring mvc 框架问题是,我有 1 个页面,其中包含多个复选框迭代唱 thymeleaf th:each iterator。当我单击多个复选框时,我想将复选框值传递给控制器​​方法..

html内容

<table> 
<tr th:each="q : ${questions}">
 <h3 th:text="${q.questionPattern.questionPattern}"></h3> 
<div>
 <p >
 <input type="checkbox" class="ads_Checkbox" th:text="${q.questionName}" th:value="${q.id}" name="id"/>
 </p>
 </div>
 </tr>
 </table> 
Run Code Online (Sandbox Code Playgroud)

*控制器*

 @RequestMapping(value = Array("/saveAssessment"), params = Array({ "save" }))
  def save(@RequestParam set: String, id:Long): String = {
  var userAccount: UserAccount = secService.getLoggedUserAccount
    println(userAccount)
    var questionSetQuestion:QuestionSetQuestion=new QuestionSetQuestion
        var questionSet: QuestionSet = new QuestionSet
    questionSet.setUser(userAccount)
    questionSet.setSetName(set)
    questionSet.setCreatedDate(new java.sql.Date(new java.util.Date().getTime))
   questionSetService.addQuestionSet(questionSet)
     var list2: List[Question] = questionService.findAllQuestion
    var limit=list2.size
     var …
Run Code Online (Sandbox Code Playgroud)

spring thymeleaf

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

设置蒲公英数据表中可见行的数量

我希望蒲公英数据表一次显示15行,而不是默认的10行。有人可以告诉我如何做到这一点吗?

这是一些我使用分页控件一次显示10行的代码,以在10行的集合之间滚动:

<datatables:table id="mydata" data="${mydataset}" cdn="true" row="mr" theme="bootstrap2" 
    cssClass="table table-striped" paginate="true" info="false" 
    cssStyle="width: 150px;" align="left" dom="frtp">
    <datatables:column title="Concept Type" cssStyle="width: 150px;" display="html">
        <c:out value="${mr.something}"/>
    </datatables:column>
</datatables:table>
Run Code Online (Sandbox Code Playgroud)

java spring jsp spring-mvc dandelion

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

Spring Java Config和Thymeleaf - 蒲公英数据表配置

尝试使用Thymeleaf和蒲公英对数据表进行分页.根据文档我需要更新一些东西:

web.xml(javaconfig尝试进一步向下)

<!-- Dandelion filter definition and mapping -->
<filter>
   <filter-name>dandelionFilter</filter-name>
   <filter-class>com.github.dandelion.core.web.DandelionFilter</filter-class>
</filter>
<filter-mapping>
   <filter-name>dandelionFilter</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Dandelion servlet definition and mapping -->
<servlet>
   <servlet-name>dandelionServlet</servlet-name>
   <servlet-class>com.github.dandelion.core.web.DandelionServlet</servlet-class>
</servlet>
<servlet-mapping>
   <servlet-name>dandelionServlet</servlet-name>
   <url-pattern>/dandelion-assets/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)

SpringTemplateEngine @Bean(跳过,因为我已经有了Thymeleaf模板引擎)

<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
   <property name="templateResolver" ref="templateResolver" />
   <property name="additionalDialects">
      <set>
         <bean class="com.github.dandelion.datatables.thymeleaf.dialect.DataTablesDialect" />
      </set>
   </property>
</bean>
Run Code Online (Sandbox Code Playgroud)

我对Spring的了解仍然非常不稳定,但我必须更换web.xml组件(至少我认为我可以这样做):

public class Initializer extends
        AbstractAnnotationConfigDispatcherServletInitializer...

    @Override
    protected Class<?>[] getServletConfigClasses() {
        logger.debug("Entering getServletConfigClasses()");
        return new Class<?>[] { ThymeleafConfig.class, WebAppConfig.class, DandelionServlet.class };
    } 

    @Override
    protected Filter[] getServletFilters() {
        return new Filter[] …
Run Code Online (Sandbox Code Playgroud)

spring-mvc datatables spring-security thymeleaf dandelion

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

Spring Boot + Thymeleaf +蒲公英配置不起作用

我正在使用Thymeleaf的Spring Boot,现在我想添加蒲公英数据表,但它不起作用.

这是我的maven依赖项:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.1.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<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>

<!-- Dandelion -->
<dependency>
    <groupId>com.github.dandelion</groupId>
    <artifactId>datatables-thymeleaf</artifactId>
    <version>0.10.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我正在遵循本指南http://dandelion.github.io/dandelion/docs/installation/thymeleaf.html并配置以下bean:

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    public FilterRegistrationBean dandelion() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new DandelionFilter());
        registrationBean.addUrlPatterns("/*"); …
Run Code Online (Sandbox Code Playgroud)

java spring thymeleaf spring-boot dandelion

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

春季批处理:在CompositeItemWriter中使用之前和之后的方法

我需要从数据库读取数据,然后生成XLSX文件并更新数据库中的数据。

读者部分没有问题。对于CompositeItemWriter编写器部分,我最终创建了一个,由第一个Writer生成XLSX文件和第二个更新db中的数据组成。

问题:我需要在第一个编写器的执行步骤之前和之后进行拦截,以便能够按块正确地写入XLSX文件。但是,一旦我将两个作者都组合成一个CompositeItemWriter,用@BeforeStepet 注释的方法@AfterStep就不会被调用。

使第一个编写器实现时出现相同的问题StepExecutionListener

知道为什么吗?

以下是CompositeItemWriter定义,步骤和编写器:

public CompositeItemWriter<Adhesion> compositeItemWriter() {
  CompositeItemWriter writer = new CompositeItemWriter();
  writer.setDelegates(Arrays.asList(adhesionToXlsWriter,  adhesionToDbWriter));
  return writer;
}

@Bean
public Step xlsStep(ItemReader<Adhesion> adhesionFromDbReader) {
   return stepBuilderFactory.get(JOB_NAME + "-step")
      .<Adhesion, Adhesion>chunk(10)
      .reader(adhesionFromDbReader)
      .writer(compositeWriter())
      .build();
   }


@Component
public class AdhesionToXlsWriter implements ItemWriter<Adhesion> {

   @BeforeStep
   public void beforeStep(StepExecution stepExecution) {
      // !! never called !!
   }

   @Override
   public void write(List<? extends Adhesion> items) throws Exception {
      // generate …
Run Code Online (Sandbox Code Playgroud)

spring-batch

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