泛型 - 如何返回T的Map?(Generics - how to return a Map of T?)
class MyObject{} class Human extends MyObject{} public ConcurrentSkipListMap<String, <T extends MyObject>> get(Class<T> clazz, Object... vars){ //... } //use the get() with ConcurrentSkipListMap<String, Human> mapOfAllAdams = get(Human.class, "Adam");
但是,返回值
ConcurrentSkipListMap<String, <T extends MyObject>>
给出编译错误,但是<T extends MyObject>T
可以。 我应该写什么呢?class MyObject{} class Human extends MyObject{} public ConcurrentSkipListMap<String, <T extends MyObject>> get(Class<T> clazz, Object... vars){ //... } //use the get() with ConcurrentSkipListMap<String, Human> mapOfAllAdams = get(Human.class, "Adam");
However, the return value
ConcurrentSkipListMap<String, <T extends MyObject>>
gives compilation error, but<T extends MyObject>T
is ok. What should I write instead?
原文:https://stackoverflow.com/questions/50421668
更新时间:2024-01-14 15:01
最满意答案
<form id = "foo"> <input type = "text" name = "text" id = "text"/> <input type = "submit" value = "change" ></input> </form>
删除动作属性和在JavaScript中
$("#foo").submit(function(event) { event.preventDefault(); $("#result").html(''); $.ajax({ url: "action.php", type: "post", data: $(this).serialize(), success: function(){ alert("success"); $("#result").html('Submitted successfully'); }, error:function(){ alert("failure"); $("#result").html('There is error while submit'); } }); });
你不需要在提交时调用任何函数,因为你已经在使用jquery提交了
<form id = "foo"> <input type = "text" name = "text" id = "text"/> <input type = "submit" value = "change" ></input> </form>
remove action attribute and in javascript
$("#foo").submit(function(event) { event.preventDefault(); $("#result").html(''); $.ajax({ url: "action.php", type: "post", data: $(this).serialize(), success: function(){ alert("success"); $("#result").html('Submitted successfully'); }, error:function(){ alert("failure"); $("#result").html('There is error while submit'); } }); });
you don't need to call any function on submit, as u are already using jquery submit
相关问答
更多-
通过本地客户端程序获取服务器mysql数据库信息[2023-04-27]
ajax -
在回调函数中访问jQuery Ajax请求的URL(Access the URL of an jQuery Ajax Request in the Callback Function)[2022-02-08]
在成功的方法设置一个断点,然后观看 this.url 是请求的真实URL。 Set a break point in success method, then watch this.url is the real url for the request. -
尝试启用mod_rewrite并更改文件夹权限: sudo chmod 755 -R laravel_folder chmod -R o+w laravel_folder/storage Try to enable mod_rewrite and change folder permissions: sudo chmod 755 -R laravel_folder chmod -R o+w laravel_folder/storage
-
ajax没有在url中调用方法(ajax not calling method in url)[2023-10-21]
这只是新手想念的东西......在方法GetMaxMgsLength之前添加了[System.Web.Services.WebMethod]属性。 This was something only a newbie would miss... Added [System.Web.Services.WebMethod] attribute before the method, GetMaxMgsLength. -
删除动作属性和在JavaScript中 $("#foo").submit(function(event) { event.preventDefault(); $("#result").html(''); $.ajax({ ...
-
确认url助手是否在application / config / autoload.php中加载,因为您正在使用base_url() 你的视图文件名应该是newproduct.php 在基址后添加/删除 index.php来检查。 如果上面的内容不能帮助你,那么分享你得到的错误和CI版本。 Confirm if url helper is loaded in application/config/autoload.php since you are using base_url() Your view fi ...
-
使用: unescape(url) 将%2F转换为/。 你提到的url.replace行会去掉url并包括一个#字符,所以: http://mysite.com/Content/#Disc/index 会成为: Disc/index Use: unescape(url) to convert the %2F to a /. The url.replace line you mention would strip the url up to and including a # character, s ...
-
当你使用Ajax时,你必须得到网址 var APP_URL = $('meta[name="_base_url"]').attr('content'); 同时将此到head标签 然后你可以使用APP_URL var url = APP_URL+"/getSportPositions/"+sectionID; When you are using Ajax you have to get url like va ...
-
Cakephp请求找不到URL(Cakephp requested URL not found)[2023-08-30]
请遵循名称惯例,如@Joseph所说 我遇到了同样的问题,它是由mod_rewrite引起的,就像@dhofstet说的那样。 解决它,然后一切正常。 如何修复它取决于您的Web服务器的配置。 (http://book.cakephp.org/2.0/en/getting-started.html#a-note-on-mod-rewrite) Please follow the name convention, like @Joseph said I encounter the same issue, it ... -
传递给$.fancybox的对象中没有href属性。 尝试在'type' : 'iframe'之后添加'type' : 'iframe' (当然,你也需要'iframe'之后的逗号): 'href' : $(this).attr('href') There's no href property in the object passed to $.fancybox. Try adding this after 'type' : 'iframe' (you'll need a comma after 'ifr ...