如何把Map转化为query string呢?
什么是query string?
即型如name=whuang&age=27
- private String getRequestBodyFromMap(Map parametersMap,boolean isUrlEncoding/*,String charset*/) {
- StringBuffer sbuffer = new StringBuffer();
- for(Object obj:parametersMap.keySet()){
- String value=(String) parametersMap.get(obj);
- if(isUrlEncoding){
- try {
- value = URLEncoder.encode(value, SystemHWUtil.CHARSET_UTF);
- if(!ValueWidget.isNullOrEmpty(value)){
- parametersMap.put(obj, value);
- }
- } catch (UnsupportedEncodingException e1) {
- e1.printStackTrace();
- }
- }
- sbuffer.append(obj).append("=").append(value).append("&");
- }
- return sbuffer.toString().replaceAll("&$", SystemHWUtil.EMPTY);
- }
- private StringBuffer getRequestBodyFromList(List<ParameterIncludeBean> parameters,boolean isUrlEncoding/*,String charset*/) {
- StringBuffer sbuffer = new StringBuffer();
- int size = parameters.size();
- for (int i = 0; i < size; i++) {
- ParameterIncludeBean parameterIncludeBean = parameters.get(i);
- if(parameterIncludeBean.isIgnore()){
- parameters.remove(parameterIncludeBean);
- size--;
- i--;
- continue;
- }
- sbuffer.append(parameterIncludeBean.getQueryString(isUrlEncoding,urlEncodeParameterCharset));
- if (i < size - 1) {
- sbuffer.append("&");
- }
- }
- return sbuffer;
- }
表格执行完
parameterTable_1.setModel(model); 之后一定要render,即
- /***
- * setCellEditor and setCellRenderer
- */
- public void rendTable(){
- parameterTable_1.getColumnModel().getColumn(2)
- .setCellEditor(new MyButtonEditor());
- parameterTable_1.getColumnModel().getColumn(2)
- .setCellRenderer(new MyButtonRender());
- if(AutoTestPanel.isTF_table_cell){//若表格的单元格是JTextField
- parameterTable_1.getColumnModel().getColumn(0)
- .setCellEditor(new MyTextFieldEditor());
- parameterTable_1.getColumnModel().getColumn(0)
- .setCellRenderer(new MyTextFieldRender());
- parameterTable_1.getColumnModel().getColumn(1)
- .setCellEditor(new MyTextFieldEditor());
- parameterTable_1.getColumnModel().getColumn(1)
- .setCellRenderer(new MyTextFieldRender());
- }
- final MouseInputListener mouseInputListener = getMouseInputListener(parameterTable_1,RequestPanel.this,null);
- parameterTable_1.addMouseListener(mouseInputListener);
- }
时间: 2024-09-16 10:33:27