首页 \ 问答 \ Post方法一个文件和字符串请求到弹簧休息控制器接收字节[]和字符串使用角?(Post method a file and string request to spring rest controller that receive byte[] and Strings using angular?)

Post方法一个文件和字符串请求到弹簧休息控制器接收字节[]和字符串使用角?(Post method a file and string request to spring rest controller that receive byte[] and Strings using angular?)

如何使用角度发送包含文件和另一个字符串请求参数到弹簧休息控制器的post方法?

服务器控制器参数接收封装在一个实体中的字节文件和其他字符串请求的数组。 我已经在这方面工作了2天没有合适的方法来做到这一点。

这里是控制器,封装的请求实体,使用角度资源的post方法和来自服务器的错误的图像:

在这里输入图像描述


How to send a post method that contains a file and another string request parameter to a spring rest controller using angular ?

The server controller parameter receives an array of byte file and other String request which is encapsulated in one entity. I've been working on this for 2 days with no suitable ways for did this.

Here is the image for controller, encapsulated request entity, post method using angular resources, and error from server:

enter image description here


原文:https://stackoverflow.com/questions/40375270
更新时间:2022-07-08 10:07

最满意答案

这有点棘手,因为标准事件不适用于自定义组件,因为当您执行以下操作时:

<mycomponent @click="method"></mycomponent>

组件正在寻找来自另一个组件的发出事件,它不知道你的意思是好的,旧的DOM点击事件。

一个选项是从子组件发出click事件,在你的情况下是Icon.vue ,但这不是最好的解决方案

还有一个,它是事件的.native修饰符,类似这样:

<div id="top-row">
  <icon name="arrow-left" class="but-0" v-bind:class="{ active: pushed0 }" aria-hidden="true" @mousedown.native="toneButtonPushed(0)"></icon>
  <icon name="arrow-left" class="but-1" v-bind:class="{ active: pushed1 }" aria-hidden="true" @mousedown.native="toneButtonPushed(1)"></icon>
</div>

通过执行此操作,您说要使用来自DOM的标准mousedown事件的组件,并且它不会查找已发出的事件。

演示: http//jsbin.com/sanivevuxa/edit?html,js,console,output


It's a bit tricky, because standard events doesn't work on the custom components because when you do something like this:

<mycomponent @click="method"></mycomponent>

Component is looking for emitted event from another component, It doesn't know that you mean on good, old DOM click event.

One option would be emitting click event from child component, in your case Icon.vue, but that's not the best solution

There is another one, it's .native modifier on event, something like this:

<div id="top-row">
  <icon name="arrow-left" class="but-0" v-bind:class="{ active: pushed0 }" aria-hidden="true" @mousedown.native="toneButtonPushed(0)"></icon>
  <icon name="arrow-left" class="but-1" v-bind:class="{ active: pushed1 }" aria-hidden="true" @mousedown.native="toneButtonPushed(1)"></icon>
</div>

By doing this you are saying component that you want to use standard mousedown event from DOM, and It won't look up for emitted one.

Demo: http://jsbin.com/sanivevuxa/edit?html,js,console,output

相关问答

更多
  • 如果你愿意,你可以使用JQuery,它可以帮助你获得你想要的东西。 var timesClicked = 0; $(".fa-heart-o").on("click",function(){ timesClicked++; document.getElementById('timesClicked').innerHTML = timesClicked; });
    这是因为网格动作列图标呈现为接受图标(路径)作为选项的IMG标签。 为了能够使用它,你必须重写Ext.grid.column.Action *defaultRenderer*方法,以支持图标旁边的glyph config选项(并且在你的代码上你可以决定相当于每个图标img或glyph对任何视图采取行动)。 工作(在ExtJS 5.0.1上测试过,但我认为它也适用于ExtJS 4)代码: Ext.define('MyApp.overrides.grid.column.Action', { overri ...
  • FontAwesome图标不是图像。 他们是字体 ,这就是为什么他们回应CSS color属性更改。 为了获得类似的效果,您需要另一个库提供这样的字体图标的标尺图标。 当FontAwesome没有特定的图标时,我通常会去FlatIcon 。 从那里你可以下载图标作为字体。 FlatIcon.com的步骤是: 将选定的图标添加到集合中。 以IconFont格式下载集合。 这将下载一个包含CSS文件和另一组字体文件(适用于不同浏览器)的zip文件。 现在,您可以简单地在HTML页面中引用此CSS文件,并通过向元 ...
  • 不。字体Awesome不使用图像作为图标,没有src属性的img元素是无效的HTML。 你可以做的是添加逻辑来显示或隐藏图像旁边的虚拟图标。 以下是在父包装器上使用class的示例:
    当父div元素具有.show-icon类时,您可以使用CSS显示图标并隐藏图像: div i.fa { display: none; } div ...
  • 火灾转向svg后,“我”标记注释,使用一些包裹 "i" tag comments out after fire turning to svg, use some wrap
  • 这是两个框架使用相同类名作为其图标的情况。 我相信,例如他们都使用了一类.icon-cart但是有不同的图像 如果您需要编辑与明确标识哪个相关的CSS类。 因此,您可以编辑CSS,以便FontAwesome类(例如) .awesome-icon-cart将其与Bootstrap字形区分开来......等等。 This is a case of both frameworks using the same class names for their icons. I believe, for instance ...
  • .fa.fa-battery-full { -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); -ms-transform: rotate(-90deg); -o-transform: rotate(-90deg); transform: rotate(-90deg); }
    这有点棘手,因为标准事件不适用于自定义组件,因为当您执行以下操作时: 组件正在寻找来自另一个组件的发出事件,它不知道你的意思是好的,旧的DOM点击事件。 一个选项是从子组件发出click事件,在你的情况下是Icon.vue ,但这不是最好的解决方案 还有一个,它是事件的.native修饰符,类似这样:
  • 您可以通过使用pseudo-element :before来实现此目的。 我为你做了这个,你可以看到。 你必须为自己设计风格,它只是向你展示它是如何完成的。 http://jsfiddle.net/1BJK903/804jeg82/332/ A .fa:before { position: absolute; } 所以在你的情况下,这将是:
    A
    C ...
  • 我想你想要减小font-size并将其提升一点点。 h4 { position: relative; } h4 .fa { font-size: 12px; position: absolute; right: -20px; top: -3px; } 为了提升图标,您可以像我在这里一样使用绝对位置,或者您可以保持display inline block并使用margin-top: -5px或其他东西来提升它。 I guess you want to reduce ...

相关文章

更多

最新问答

更多
  • 您如何使用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)