Spring MVC和Thymeleaf防止实体Id泄漏(Spring MVC and Thymeleaf Prevent Entity Id Leak)
我有
Demand
实体。 我可以毫无问题地更新我的实体,但我认为我的approch有一些安全问题。demandController
@RequestMapping(value = "/details/{id}", method = RequestMethod.POST) public String updateDemand(@PathVariable("id") Long id, @Valid @ModelAttribute Demand demand, BindingResult result) { if (result.hasErrors()) { return "demandUpdateForm"; } else { demand.setDemandId(id); demandService.updateDemand(demand); return "redirect:/demands"; } }
serviceImpl
@Override public Demand updateDemand(Demand demand) { return demandRepository.save(demand); }
形成
<form id="vendorForm" th:action="@{/demands/details/__${demand.demandId}__}" th:object="${demand}" method="post" >
如你所见,我从行动中得到了
DemandId
。 例如,我想更新第5个id的demand
并获取更新表单。 然后我通过开发人员工具更改了demandId
并单击“提交”。 如果我修改id例如2nd和表单更新我的第二个iddemand
不是原来的第5个。 我该如何防止这种情况发生。I have
Demand
entity. I can update my entity without any problem but I think my approch have some security problem.demandController
@RequestMapping(value = "/details/{id}", method = RequestMethod.POST) public String updateDemand(@PathVariable("id") Long id, @Valid @ModelAttribute Demand demand, BindingResult result) { if (result.hasErrors()) { return "demandUpdateForm"; } else { demand.setDemandId(id); demandService.updateDemand(demand); return "redirect:/demands"; } }
serviceImpl
@Override public Demand updateDemand(Demand demand) { return demandRepository.save(demand); }
form
<form id="vendorForm" th:action="@{/demands/details/__${demand.demandId}__}" th:object="${demand}" method="post" >
As you see I get
DemandId
from action. For example I want to update 5th id'sdemand
and get the update form. Then I changeddemandId
via developer tools and click submit. If I modify id for example 2nd and form update my 2nd iddemand
not original the 5th one. How can I prevent this situation.
原文:https://stackoverflow.com/questions/37533894
更新时间:2023-07-27 20:07
最满意答案
使用
innerHTML
而不是value
:document.getElementById("demo").innerHTML = '';
Use
innerHTML
instead ofvalue
:document.getElementById("demo").innerHTML = '';
相关问答
更多-
检索Google搜索结果(retrieving Google search results)[2023-05-04]
您更改索引: echo $x->responseData->results[1]->url; 循环遍历所有: foreach ($x->responseData->results as $r) { echo $r->url, "\n"; } 您可以使用var_dump($x);检查完整结果var_dump($x); 。 要检索另一页结果,可以使用start参数,例如: $x = json_decode( file_get_contents( 'http://ajax.google ... -
MySQL标签搜索(MySQL tag search)[2023-05-17]
使用图像存储标签的更好解决方案是创建一个单独的表,其中标签链接到图像。 然后,您将为每个标记创建一行,例如 image_file (FK) tag --------------- ----------- test.png tag1 test.png another_tag test.png tag2 hi.jpg tag9 hi.jpg tag1 hi.jpg another_tag hi.jpg ... -
使用innerHTML而不是value : document.getElementById("demo").innerHTML = ''; Use innerHTML instead of value: document.getElementById("demo").innerHTML = '';
-
搜索div(Search into divs)[2022-08-05]
你的HTML无效。 tr元素只能有td或th子元素。 你应该用td元素包装tr内容。 这就是我的Chromium浏览器呈现你的html的方式:Panel 1data.query.search,我认为它应该是data.data和里面的函数data.title有些想像... $.each(data.data, function(i, data) { $("#results").append(data.title+" "+data.permalink); }); data.query.search, I think it should be data.data and inside function data.title some think like... $.e ...搜索html中的内容(Search the contents in the html)[2023-07-05]
您错误地将我的错误告诉了我...请仔细检查您的HTML代码! 您希望使用id为'row1-1'的li节点内的span元素获取文本。 这可以翻译成$html->find('li#row1-1', 0)->plaintext; 这是一个完整的工作代码: $input = <<<_DATA_- 4:00 PM ...
据我所知,来自http://angular-ui.github.io/bootstrap/的typeahead指令的代码(自从我写完之后我就知道了:-))你将无法只按配置做你在这里问的事。 您需要分叉并根据您的需求进行调整。 它应该非常简单。 如果您觉得应该在指令中更改任何内容以便更容易扩展,请随意打开GitHub问题。 As far as I know the code of the typeahead directive from http://angular-ui.github.io/bootstra ...根据
标签内容搜索pdf页面(Search pdf page based ontag contents)[2021-12-03]PDF没有元素,因此无法搜索它们。 虽然URL地址暗示您的示例文件是PDF,但如果查看其源代码,您可以看到它只是一个纯HTML文件。 PDF's don't haveelements, so there's no way to search for them. Although the URL address implies your example file is a PDF, if you look at its source code, you can see that it' ...jqueryUI自动完成 - 无论搜索结果如何,始终附加选项(jqueryUI autocomplete - always append an option regardless of search results)[2022-10-08]
这是您缺少的方法,您只需要访问ui.content属性。 response: function( event, ui ) { //console.log(ui.content); ui.content.unshift({value:"Add new account", label:"Add new account"}); } 这是工作的例子。 $( function() { var availableTags = [ "ActionScript", ...twitter API的第1版已被弃用, 正在删除 。 不确定如何错过twitter开发站点上的巨大警告;)这意味着像上面这样简单的代码将不再起作用 。 因此,您现在需要使用1.1 API进行经过身份验证的请求(OAuth),并且它就像在(使用PHP) file_get_contents(http://search.twitter.com/ ...)那样简单。 我在你的个人资料中看不到你使用的任何服务器端语言,但我写了一篇冗长的帖子解释了这个问题 (图片)以及如何使用php库来执行经过身份验证的请求。 Ve ...相关文章
更多- Spring MVC 3 深入总结
- Thymeleaf标准方言SpringStandard
- Spring MVC与表单提交的问题
- Spring MVC文件上传
- Thymeleaf+SpringMVC5示例教程
- Spring MVC 入门实例教程
- Spring Boot CLI 基于Thymeleaf的示例
- 请教关于spring mvc中使用json-lib-ext-spring返回json的问题
- Spring MVC入门
- spring3MVC +spring security3 关于扩展UserDetailsService 无法注入service的疑问.
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。