小编Mar*_*arc的帖子

如何将Spring模型属性作为参数传递给Thymeleaf片段

我有一个简单的基于CRUD thymeleaf的html页面,其中列出了工人和工人的详细信息.现在我想创建,编辑或删除一个工人.对于此操作,我使用twitter bootstrap模式对话框.

这工作正常,但我有很多重复,所以我想创建一个th:片段,其中包含在详细信息视图中相同的表单字段,创建视图和编辑视图.只是弹簧模型属性是不同的.

<div th:fragment="workerForm(formId, formAction, worker)">
  <form th:id="${formId}" th:action="${formAction}" class="form-horizontal" method="post" role="form">
    <div class="form-group">
      <label for="inputGivenName" class="col-sm-2 control-label">Givenname</label>
      <div class="col-sm-10">
        <input id="inputGivenName" type="text" class="form-control" th:field="${worker.givenName}"/>
      </div>
    </div>
    <div class="form-group">
      <label for="inputName" class="col-sm-2 control-label">Name</label>
      <div class="col-sm-10">
        <input id="inputName" type="text" class="form-control" th:field="${worker.name}"/>        
      </div>
    </div>        
    <div class="form-group">
      <div class="col-sm-offset-2 col-sm-10">        
        <div class="checkbox">        
          <label>
          <input type="checkbox" th:field="${worker.active}"/> Active
          </label>
        </div>
      </div> 
    </div>                          
  </form>
</div>
Run Code Online (Sandbox Code Playgroud)

现在我想在模态对话框中包含这个片段...

<div class="modal-body">
  <div th:include="workerFragments :: workerForm(newWorkerForm, @{/worker/new}, ${newWorker})"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

是否可以将模型属性newWorker作为参数传入片段,而thymeleaf将使用此而不是$ {worker}

NewWorker在spring动作中设置为:

.... …
Run Code Online (Sandbox Code Playgroud)

spring thymeleaf

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

Spring WS:为什么 Spring WS 返回 WebServiceTransportException 而不是 SoapFaultException

我在调用 Web 服务时遇到问题,Spring WS 仅返回 WebServiceTransportException: Internal Server Error 而不是预期的 SoapFaultException。当我在 SOAPUI 中触发调用时,出现肥皂错误。

WebServiceTransportException 还抑制响应的输出,因此我在日志中看不到问题所在。

我在带有配置类的 Spring Boot 应用程序中使用 Spring WS。

public class SoapClientConfig {

private static Logger log = LoggerFactory.getLogger(SoapClientConfig.class);

private static final int DEFAULT_CONNECTION_TIMEOUT_MILLISECONDS = 60000;
private static final int DEFAULT_READ_TIMEOUT_MILLISECONDS = 60000;
private static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE = 2;

public static final int CONNECTION_REQUEST_TIMEOUT = 30000;

@Value("${soap.client.proxy.host}")
protected String proxyHost;
@Value("${soap.client.proxy.port}")
protected String proxyPort;
@Value("${soap.client.max.connections}")
private int maxConnections;

public Jaxb2Marshaller createMarshaller(String packageName) throws Exception {
    Jaxb2Marshaller jaxb2Marshaller …
Run Code Online (Sandbox Code Playgroud)

spring soap web-services spring-ws

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

Spring boot JSF可执行JAR找不到xhtml文件

我遇到的问题是,我的 Spring Boot JSF 应用程序可以在 IntelliJ 中运行,但不能作为可执行 JAR 运行。应用程序启动时没有问题,但无法解析 xhtml 模板。在 IntelliJ 中,一切都按预期进行。

我发现这个问题涉及类似的问题。我查看了文件结构,看不出有什么区别。

Spring Boot JSF 打包为 JAR

我的maven文件结构:

  src
   | main
      | resources
           | META-INF
               | resources
                    | index.xhtml
               | faces-config.xml
Run Code Online (Sandbox Code Playgroud)

因此,当我启动 Spring Boot 应用程序时,它将在目标/类处获取

那里的结构是:

 target
   | classes
        | META-INF
             | resources
                  | index.xhtml
             | faces-config.xml
Run Code Online (Sandbox Code Playgroud)

在创建的可执行 JAR 中,结构为

  org
  BOOT-INF
     | lib
     | classes
         | de ...
  META-INF
     | resources
         | index.xhtml
     | faces-config.xml
Run Code Online (Sandbox Code Playgroud)

据我了解各种网站和答案,这应该是 jar 中获取 xhtml 文件的正确结构。但这对我不起作用。出于无奈,我将 META-INF 目录复制到 BOOT-INF/classes 目录中,并在另一次迭代中将 META-INFO 中的资源目录复制到 BOOT-INF/classes …

xhtml jsf executable-jar maven spring-boot

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