首页 \ 问答 \ SpringBoot MVC - 发布ThymeLeaf对象(SpringBoot MVC - Post ThymeLeaf Object)

SpringBoot MVC - 发布ThymeLeaf对象(SpringBoot MVC - Post ThymeLeaf Object)

我想知道是否可以使用ThymeLeaf和SpringBoot发布一个对象?

我在网上看过,但它似乎没有很好的记录。

我知道下面的代码不起作用,但它显示了我想实现的一般要点。

请假设有一个对象被传入视图,称为Part的“部分”。

控制器:

@Controller
@RequestMapping("/basket")
public class BasketController {
@RequestMapping(value = "/add", method = RequestMethod.POST)

public ModelAndView addToBasket(@ModelAttribute("part") Part part) {

 ModelAndView mv = new ModelAndView("basket/viewBasket");
 return mv;

}
}

和观点:

<form method="POST" th:action="@{/basket/add}" th:object="${part}" modelAttribute="part">
                <input th:object="${part}"/>
                <input type="submit" class="btn btn-warning btn-block" th:value="#{basket.add}"/>
            </form>

谢谢!


I was wondering whether or not it would be possible to POST an object using ThymeLeaf and SpringBoot?

I have looked online but it doesn't seem to be very well documented.

I know the below code doesn't work but it shows the general gist of what I want to achieve.

Please assume that there is an object passed into the view called "part" of type Part.

The Controller:

@Controller
@RequestMapping("/basket")
public class BasketController {
@RequestMapping(value = "/add", method = RequestMethod.POST)

public ModelAndView addToBasket(@ModelAttribute("part") Part part) {

 ModelAndView mv = new ModelAndView("basket/viewBasket");
 return mv;

}
}

And the view:

<form method="POST" th:action="@{/basket/add}" th:object="${part}" modelAttribute="part">
                <input th:object="${part}"/>
                <input type="submit" class="btn btn-warning btn-block" th:value="#{basket.add}"/>
            </form>

Thanks!


原文:https://stackoverflow.com/questions/48113441
更新时间:2022-07-30 18:07

最满意答案

RCU和WCU(读/写容量单位)总是在所有分区之间平均分配。

所以,要回答你的问题,你最终会得到2个分区,每个分区分别有250个RCU和WCU。


RCUs and WCUs (Read/Write Capacity Units) are always equally divided among all partitions.

So, to answer your question, you'll end up with 2 partitions, each with 250 and 25 RCUs and WCUs respectively.

相关问答

更多
  • 伊戈尔, 分区增加了卡夫卡主题的并行性。 任何数量的消费者/生产者都可以使用相同的分区。 它直到应用层来定义协议。 卡夫卡保证交付。 关于API,您可能希望查看Java文档,因为它们可能更完整。 根据我的经验: 分区从0开始 密钥可用于将消息发送到同一分区。 例如hash(key)%num_partition。 该逻辑可插入Producer。 https://kafka.apache.org/090/javadoc/index.html?org/apache/kafka/clients/producer/P ...
  • super.type只是引用与this.type相同的变量...只涉及一个对象,因此只有一个字段。 当您创建子类的实例时,它不会创建两个单独的对象,一个用于超类,一个用于子类 - 它创建一个对象,可以将其视为超类或子类。 它有一组字段。 在这种情况下,您有一个字段( type ),其最初的值为"f " ,但其值已更改为"c " 。 super.type is just referring to the same variable as this.type... there's only one object ...
  • RCU和WCU(读/写容量单位)总是在所有分区之间平均分配。 所以,要回答你的问题,你最终会得到2个分区,每个分区分别有250个RCU和WCU。 RCUs and WCUs (Read/Write Capacity Units) are always equally divided among all partitions. So, to answer your question, you'll end up with 2 partitions, each with 250 and 25 RCUs and ...
  • 本质上,分区的下限和上限以及分区的数量用于计算每个并行任务的增量或拆分。 假设该表的分区列为“年”,并且具有从2006年到2016年的数据。 如果您将分区数量定义为10,并且2006年的下限和2016年的上限,则您可以让每项任务获取本年度的数据 - 理想情况。 即使您错误地指定了下限和/或上限,例如设置lower = 0和upper = 2016,数据传输也会出现偏差,但是,您不会“丢失”或无法检索任何数据,因为: 第一项任务将获取年份<0的数据。 第二项任务将获取0至2016/10年度的数据。 第三项任务 ...
  • Truncate删除表的数据文件。 它不会从Metastore中删除分区定义。 它不会删除文件系统目录。 演示 hive> create table mytable (i int) partitioned by (p int); OK hive> insert into mytable partition (p) values (1,10),(2,10),(3,20),(4,30),(5,30),(6,30); OK hive> select * from mytable; OK mytable.i ...
  • 是的,这在理论上是可行的。 示例数据强制某种形式的偏好(可能有一个更简单的例子): rdd1 = sc.range(10).map(lambda x: (x % 4, None)).partitionBy(8) rdd2 = sc.range(10).map(lambda x: (x % 4, None)).partitionBy(8) # Force caching so downstream plan has preferences rdd1.cache().count() rdd3 = rdd1. ...
  • 碎片是Crate最小的“数据单元”,表格应该具有适当的数量(我不知道是一种精确的科学),以便在整个群集中均匀分布数据(以及工作负载范围),因为这是在碎片。 目前,没有直接控制放置(在哪个节点上)和特定分片的复制。 一个分片对应多少个分区? 实际上它是另一种方式:分区有一些分片,因为分区被视为“子表”,其中包含数据子集。 从原始CREATE TABLE语句创建分区(它用作模板),因此甚至可以具有与其他分区不同的分片计数。 我可以配置将特定分区的数据作为特定分片的一部分发送吗? 好吧,不 - 不明确。 分片管理 ...
  • 您的代码的第一个版本 while (cin >> val) { 尝试解析一个浮点数, 然后检查流状态是否良好。 (具体来说,它会调用operator>>执行提取操作,它将在发生错误时设置failbit ,然后使用布尔转换来测试failbit )。 因此,如果流状态不好(因为它不能转换为浮点数),则不会输入循环体。 因此,它终止于第一次失败的转换。 第二个版本 while (cin) { cin >> val; 检查流状态是否正常(它只是告诉你以前的转换成功),然后尝试解析一个浮点 ...
  • 与您的断言相反,第一个表无错误地工作,将示例数据插入其中: INSERT INTO `ox_data_archive_20120108` VALUES (1, 2, 3, '2012-01-31 04:10:03'); 导致与第二个表相同的错误。 错误中给出的值(734898)恰好是to_days('2012-01-31') 。 您收到此错误的原因是您在2010年1月1 日至3日期间只有分区。示例数据的日期和年份都在定义的分区之外。 而不是TO_DAYS (返回从第0年到给定日期的天数),您可能想要DAY ...
  • 会在每个执行器上一次触发进程1分区,或者如果执行器具有足够的内存和内核,它将在每个执行器上并行处理多个分区。 Spark将根据您正在运行的作业可用的核心总量来处理每个分区。 假设您的流式作业有10个执行器,每个执行器都有2个内核。 这意味着您可以同时处理10 x 2 = 20个分区, spark.task.cpus是spark.task.cpus设置为1。 如果您真的想要详细信息,请查看Spark Standalone从CoarseGrainedSchedulerBackend请求资源,您可以查看它的mak ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)