java - 如何将阔叶百里香切换到 angularjs ui

标签 java angularjs spring-mvc broadleaf-commerce

我想将 Broadleaf thymeleaf ui 更改为 AngularJS。

已编辑

    <!-- Commented bean -->
<!-- <bean class="org.broadleafcommerce.common.web.BroadleafThymeleafViewResolver">
        <property name="templateEngine" ref="blWebTemplateEngine" />
        <property name="order" value="1" />
        <property name="cache" value="${thymeleaf.view.resolver.cache}" />
        <property name="characterEncoding" value="UTF-8" />
    </bean> -->

Added new viewresolver
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/templates/</value>
        </property>
        <property name="order" value="1" />
    </bean>

排除百里香 jar 并添加所有 bean 类 根据http://www.broadleafcommerce.com/docs/core/current/appendix/removing-thymeleaf

加载页面时出错

在名为“mycompany”的 DispatcherServlet 中未找到带有 URI [/WEB-INF/templates/index.html] 的 HTTP 请求的映射

最佳答案

为什么要完全删除 Thymeleaf?你想做同构吗?如果没有,您所要做的仍然是渲染 Thymeleaf 模板,但使用它只在页面上包含 AngularJS 库,而不是在 Thymeleaf 中执行任何其他操作。然后,您只需在前端编写所有内容,就像使用普通的 Angular 应用程序一样。

此外,如果您使用的是 Broadleaf Controller (演示应用程序中提供的 Controller ),那么如果您想完全更改模板结构,则需要更改几乎所有 Controller (或者直接扔掉它们)。在这种情况下, Controller 返回“index”,但现在 Spring 不知道如何解释“/WEB-INF/templates/index.html”,因为您删除了 View 解析器。

关于java - 如何将阔叶百里香切换到 angularjs ui,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35315655/

相关文章:

java - SQL 返回解密的密码

java - 如何在 Primefaces 2.2.1 中为 JSF2 自定义终端组件?

java - 匹配字符串的模式

javascript - Angular 用户界面 : Correctly updating the models between two lists with a filter applied

javascript - "400 Bad Request"AJAX 请求响应

java - 需要绕过 WCF 对响应消息的解密

javascript - 如何使用 Promise 中的值异步更新 AngularJS 状态

html - 对齐输入字段和按钮

java - 如何在 hibernate 中重用 Criteria 对象?

spring - 如何在 Spring Controller 中使用 @RequestParam(value ="foo") Map<MyEnum, String> ?