小编Ana*_*kzz的帖子

Spring Jquery Ajax Post上的400错误请求

我在这个POST请求上收到400个错误请求.知道这里的问题是什么吗?日志在这里.

调节器

@Controller
public class AjaxController {
    @RequestMapping(value="/addKeys", method=RequestMethod.POST, consumes="application/json; charset=UTF-8")
    public ResponseEntity<String> addKeys(@RequestParam(value="keys") ArrayList<Keys> keys){
        System.out.println("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"+keys);
    }
}
Run Code Online (Sandbox Code Playgroud)

上下文servlet.xml中

<beans>
    <mvc:annotation-driven />
    <context:component-scan base-package="com.canon.fw.controller" />
    <bean id="defaultViews" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
</beans>
Run Code Online (Sandbox Code Playgroud)

阿贾克斯

tmpList = '[{"key":"camera","label":"Camera"},{"key":"mobile","label":"Mobile"}]';
$.ajax({
  type: 'POST',
  url: ctx+'/ajx/addKeys',
  data: JSON.stringify({"keys": tmpList }),
  success: function(r){
      if(r.model.status=='success'){
          debugger;
          //glist.push(elem.key);
          //addToList(elem.key, elem.label);
          highlightInfoDisc();
      }
  },
  dataType: 'json',
  contentType: 'application/json'
});
Run Code Online (Sandbox Code Playgroud)

FireBug - URL

http://localhost:8080/Di/ajx/addKeys
Run Code Online (Sandbox Code Playgroud)

Firebug - 响应标题

Cache-Control   must-revalidate,no-cache,no-store
Content-Length  1384
Content-Type    text/html; charset=iso-8859-1
Server  Jetty(6.1.26)
Run Code Online (Sandbox Code Playgroud)

Firebug - 请求标题 …

jquery spring-mvc http-post

8
推荐指数
1
解决办法
2万
查看次数

webpack devserver 代理到 https,给出“尝试代理请求时发生错误”和 SELF_SIGNED_CERT_IN_CHAIN

尝试设置从 localhost 到 http站点的代理时看到以下错误

[HPM] Error occurred while trying to proxy request /api/analytics/getDataByPage from localhost:8080 to https://example.com:19502 (SELF_SIGNED_CERT_IN_CHAIN) (https://nodejs.org/api/errors.html#errors_common_system_errors)
Run Code Online (Sandbox Code Playgroud)

webpack

8
推荐指数
3
解决办法
2万
查看次数

@ExtendWith(SpringExtension.class)无效

我正在尝试在spring-boot 2.x项目中使用Junit 5来测试Controller.

以下工作正常

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@WebMvcTest(TypesController.class)
@RunWith(SpringRunner.class)
public class TypesControllerTest {
    @Autowired
    WebApplicationContext wac;

    @Test
    public void testTypes() throws Exception {
        webAppContextSetup(wac).build().perform(get("/types").accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk()).andExpect(content().contentType("application/json;charset=UTF-8"));
    }

    @EnableWebMvc
    @Configuration
    @ComponentScan(basePackageClasses = { TypesController.class })
    static class Config {
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我将其更改为使用SpringExtention,

..

import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.junit.jupiter.api.extension.ExtendWith;

..
@ExtendWith(SpringExtension.class)
@WebMvcTest(TypesController.class)
public class TypesControllerTest …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc-test spring-junit spring-boot junit5

7
推荐指数
1
解决办法
5712
查看次数

使用Jquery的空文本框

单击"删除"时,我可以隐藏'tr'.使用以下代码.

$("a#minus").bind("click", function(e){
    $(this).closest('tr').hide();
});
Run Code Online (Sandbox Code Playgroud)

但我也想清除2个文本框的内容(文本框的id是动态的[frm_Expense_expensesVO_ __strAmount和frm_Expense_expensesVO_ __memo]这里'*'从1变为无穷大).请帮忙.谢谢

<table>
<tr>
    <td>
        Amount
    </td>
    <td>
        Memo
    </td>
    <td>    
        &nbsp;
    </td>
</tr>
<tr>
    <td>
        <input type="text" name="expensesVO[0].strAmount" value="2.30" id="frm_Expense_expensesVO_0__strAmount"/>
    </td>
    <td>
        <input type="text" name="expensesVO[0].memo" value="Five" id="frm_Expense_expensesVO_0__memo"/>
    </td>
    <td>
        <a id="minus" href="#">Remove</a>
    </td>
</tr>
<tr>
    <td>
        <input type="text" name="expensesVO[1].strAmount" value="3.45" id="frm_Expense_expensesVO_1__strAmount"/>
    </td>
    <td>
        <input type="text" name="expensesVO[1].memo" value="Six" id="frm_Expense_expensesVO_1__memo"/>
    </td>
    <td>
        <a id="minus" href="#">Remove</a>
    </td>
</tr>
<tr>
    <td>
        <input type="text" name="expensesVO[2].strAmount" value="" id="frm_Expense_expensesVO_2__strAmount"/>
    </td>
    <td>
        <input type="text" name="expensesVO[2].memo" value="" id="frm_Expense_expensesVO_2__memo"/>
    </td>
    <td>
        <input type="submit" …
Run Code Online (Sandbox Code Playgroud)

jquery textbox

6
推荐指数
2
解决办法
6万
查看次数

npm install -g angular-cli sh:1:node:not found

npm install -g @angular/cli
Run Code Online (Sandbox Code Playgroud)

试图在ubuntu 16.10中安装angular-cli,我在sass上遇到以下错误.

/home/user1/.npm-packages/bin/ng -> /home/user1/.npm-packages/lib/node_modules/@angular/cli/bin/ng

> node-sass@4.5.0 install /home/user1/.npm-packages/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/install.js

sh: 1: node: not found
/home/user1/.npm-packages/lib
??? (empty)

npm WARN optional Skipping failed optional dependency /@angular/cli/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.17
npm WARN @angular/core@2.4.6 requires a peer of rxjs@^5.0.1 but none was installed.
npm ERR! Linux 4.8.0-22-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "@angular/cli"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! …
Run Code Online (Sandbox Code Playgroud)

ubuntu sass angular

6
推荐指数
1
解决办法
2907
查看次数

在 useEffect 的 cleanup/return 方法中访问 useState 变量

我有一个像这样的领域

const SimpleReactComponent = (props) => {
  const [title, setTitle] = useState('DEFAULT')

  useEffect(() => {
    return () => {
      // unmount 
      console.log(`[${title}] while unmounting`)
    }
  }, [])
  return <TextInput value={title} onChangeText={title => setTitle(title)}></TextInput>
}
Run Code Online (Sandbox Code Playgroud)

当我修改该title字段并离开该组件时,它仍然打印以下内容

[DEFAULT] while unmounting

Run Code Online (Sandbox Code Playgroud)

虽然我期待新修改的值而不是DEFAULT.

如何在组件卸载时捕获更改?

reactjs react-native use-effect use-state

5
推荐指数
1
解决办法
2152
查看次数

Java继承示例

以下是继承的示例

class Parent {
    Parent(int a, int b) {
        int c = a + b;
        System.out.println("Sum=" + c);
    }
    void display() {
        System.out.println("Return Statement");
    }
}
class Child extends Parent {
    Child(int a, int b) {
        int c = a - b;
        System.out.println("Difference=" + c);
    }
}
public class InheritanceExample {
    public static void main(String args[]) {
        Child c = new Child(2, 1);
        c.display();
    }
}
Run Code Online (Sandbox Code Playgroud)

当我没有非参数化构造函数parent()时,我得到以下错误

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    Implicit super constructor Parent() is …
Run Code Online (Sandbox Code Playgroud)

java

3
推荐指数
1
解决办法
3万
查看次数

ViewController-全屏

第二个ViewController在顶部具有此空间,几乎在电话上显示为可弹出的弹出窗口。如何全屏显示(删除橙色箭头所指的空间)?

在此处输入图片说明

ios swift

2
推荐指数
1
解决办法
109
查看次数