删除Transfer-Encoding:在POST请求中分块?

我使用以下代码发送POST请求,但请求以chunked( Transfer-Encoding: chunked )的forms发送。 我搜索了这个问题并说它包含了Content-Length但是在下面的代码中我无法弄清楚如何设置Content-Length : @RequestMapping(value = “/contacts”, method = RequestMethod.POST) public Map addContactInfo( @RequestBody Map ContactInfoDto) { ContactInfo contactInfo = ContactInfoDto.get(“contact”); if (contactInfo == null) { throw new IllegalArgumentException(“Contact not found.”); } contactInfo = this.contactInfoManager.addNew(contactInfo); Map map = new HashMap(); map.put(“contact”, contactInfo); return map; }

在Http POST标头中发送非ASCII文本

我将文件作为八位字节流发送到服务器,我需要在标头中指定文件名: String filename = “«úü¡»¿.doc” URL url = new URL(“http://www.myurl.com”); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(“POST”); conn.addRequestProperty(“Accept”, “application/json; charset=UTF-8”); conn.addRequestProperty(“Content-Type”, “application/octet-stream; charset=UTF-8”); conn.addRequestProperty(“Filename”, filename); // do more stuff here 问题是,我需要发送的一些文件的文件名包含非ASCII字符。 我已经读过你不能在HTTP头中发送非ASCII文本。 我的问题是: 你能在HTTP头中发送非ASCII文本吗? 如果可以的话,你怎么做? 当filename包含非ASCII文本时,上面的代码不起作用。 服务器响应“Bad Request 400”。 如果你不能,解决这个限制的典型方法是什么?

Java Spring WS org.springframework.ws.soap.saaj.SaajSoapEnvelopeException:无法访问信封

我在不同的环境中解开了一个奇怪的spring行为。 以下在本地tomcat 7.0.29上使用Soap UI工作正常,但确实返回下面提到的错误。 servlet.xml中: classpath:ws.properties com.db.vhs.ws.jaxb.PlacementRequest com.db.vhs.ws.jaxb.PlacementResponse… scheam.xsd: 第一种方法适用于两种环境,第二种方法(placementRequest)返回: Apache Tomcat/7.0.29 – Error report HTTP Status 500 – Request processing failed; nested exception is org.springframework.ws.soap.saaj.SaajSoapEnvelopeException: Could not access envelope: Unable to create envelope from given source: ; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source: type Exception reportmessage Request processing failed; […]

如何在Hibernate中设置内部查询的限制?

我有这样的HQL: from Table1 t1 where t1.name not in (select t2.name from Table2 t2 order by t2.date limit 10) 问题是它不了解limit关键字。 有没有办法运行这样的查询而不将其分成两个子查询?

使用参数null 重载方法调用

可能重复: 方法重载NULL参数 在下面的代码中输出是 串 如果我使用String类型的参数删除方法,那么输出是 目的 我知道当参数类型不完全匹配时方法的重载是如何动作的,但是我无法理解如何将null视为Object和/或String参数。 对此有何解释? class C { static void m1(Object x) { System.out.print(“Object”); } static void m1(String x) { System.out.print(“String”); } public static void main(String[] args) { m1(null); } }

jTable和排序

如何使用单选按钮对jtable列进行排序? 我的jtable是defaultTableModel而不是向量。 我已经实现当用户按下列标题时,它将排序,现在我必须使用单选按钮实现.. 实现这一目标的最佳方法是什么?

为什么ImageReader返回错误的BufferedImage?

我试图访问21帧的动画GIF图像,然后读取第12帧(因为它从0开始?)帧。 import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.SuffixFileFilter; import org.apache.commons.io.filefilter.TrueFileFilter; public class PictureSearch { public static void search(File file) { try { ImageReader reader = (ImageReader) ImageIO.getImageReadersBySuffix(“gif”).next(); reader.setInput(ImageIO.createImageInputStream(file), false); BufferedImage caption = reader.read(12); System.out.println(caption.getHeight()); System.out.println(caption.getWidth()); caption.flush(); } catch (IOException e) […]

正则表达式匹配任何数字(真实,理性和标志)

我写了一个正则表达式来匹配任何数字: 正面及负面 十进制 真实的数字 以下正则表达式做得很好,但有一个缺点 ([\+\-]{1}){0,1}?[\d]*(\.{1})?[\\d]* 对于诸如+或– 的输入也是积极的。 任何指针将不胜感激。 谢谢。 正则表达式应该使用以下输入 5,+ 5,-5,0.5,+ 0.5,-0.5,.5,+ 5,-.5 并且不应与以下输入匹配 + – +。 – 。 。 以下是tchrist的答案,完美无缺。 (?:(?i)(?:[+-]?)(?:(?=[.]?[0-9])(?:[0-9]*)(?:(?:[.])(?:[0-9]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0-9]+))|))

从Java执行shell命令

我正在尝试从GNU / Linux平台上的Java应用程序执行shell命令。 问题是调用另一个java应用程序的脚本永远不会结束,尽管它从bash成功运行。 我试着调试它: (gdb)bt __kernel_vsyscall()中的#0 0xb773d422 pthread_join中的#1 0xb7709b5d(threadid = 3063909232,thread_return = 0xbf9cb678):pthread_join.c:89 ContinueInNewThread()中的#2 0x0804dd78 #3 0x080497f6 in main() 我尝试过:ProcessBuilder(); 和Runtime.getRuntime()。exec(cmd); 看起来它等待完成一些事情。 有任何想法吗? 谢谢Laurenţiu

在循环中创建对象的新实例以添加到列表中

我试图将对象(JavaBean)添加到列表中。 MyWebServiceRequest mywebService = new MyWebServiceRequest(); MyRequestType type= new MyRequestType (); for(int i=0; i< 9; i++){ type.setA(someDynamicValue); type.setB(someDynamicValue); mywebService.add(type); } 这只创建一个(类型)对象,因此它使用相同的数据添加相同的对象9次。 MyWebServiceRequest mywebService = new MyWebServiceRequest(); for(int i=0; i< 9; i++){ MyRequestType type= new MyRequestType (); type.setA(someDynamicValue); type.setB(someDynamicValue); mywebService.add(type); } 这会创建多个对象,添加带有diff值的9个diff对象。 如果(for循环)在一个循环中创建数百个对象而不是9个,每次发出请求时会怎么样? 那么它在内存中的转储吧? 怎么避免这个? 提前致谢。