首页 \ 问答 \ WSO2 API管理器:无论HTTP状态码如何,总是获得HTTP OK响应(WSO2 API Manager: Always got HTTP OK response regardless of HTTP status code)

WSO2 API管理器:无论HTTP状态码如何,总是获得HTTP OK响应(WSO2 API Manager: Always got HTTP OK response regardless of HTTP status code)

我尝试在自定义介体中的响应消息中设置HTTP状态代码,如下所示

<property name="HTTP_SC" value="400" scope="axis2"/>

但在回应中,我得到了这个状态

HTTP/1.1 400 OK

还有什么我需要做的,以获得与HTTP状态代码一致的正确的HTTP状态消息。

我正在使用WSO2 API Manager 2.0.0

非常感谢你。


I tried to set HTTP status code in response message in a custom mediator as followed

<property name="HTTP_SC" value="400" scope="axis2"/>

But in the response I got this status line

HTTP/1.1 400 OK

Is there anything else I need to do to get the correct HTTP status message which align with the HTTP status code.

I am using WSO2 API Manager 2.0.0

Thank you very much.


原文:https://stackoverflow.com/questions/43978392
更新时间:2023-02-23 20:02

最满意答案

nArray[i]是一个char ; '\n'常数也是如此。 字符是无符号整数类型,因此字符以与所有整数相同的方式添加在一起 ​​- 数字。 当一个加法发生时,你最终得到一个int ,而不是一个char ,所以调用println会产生一个数字结果。

删除+ '\n'将解决问题。 你会从println得到一个换行符,所以所有的字符都会出现在一行中。

演示。


nArray[i] is a char; so is the '\n' constant. Character is an unsigned integral type, so characters are added together in the same way as all integers - numerically. When an addition happens, you end up with an int, not a char, so calling println on it produces a numeric result.

Removing + '\n' will fix the problem. You would get a newline character from println, so all characters would appear on a new line.

Demo.

相关问答

更多
  • 迭代和连接方法: Character[] chars = {new Character('a'),new Character('b'),new Character('c')}; String str = ""; for (Character c : chars) str += c.toString(); System.out.println(str); 输出: ABC Iterate and concatenate approach: Character[] chars = {new Cha ...
  • 要开始你的作业, String.split将正则表达式分割字符串,此表达式可能是一个空字符串: String[] ary = "abc".split(""); 产生数组: (java.lang.String[]) [, a, b, c] 摆脱空的第一个条目留给读者练习:-) 注意:在Java 8中,不再包含空的第一个元素。 To start you off on your assignment, String.split splits strings on a regular expression, t ...
  • 用这个: String str = "testString"; char[] charArray = str.toCharArray(); Character[] charObjectArray = ArrayUtils.toObject(charArray); Use this: String str = "testString"; char[] charArray = str.toCharArray(); Character[] charObjectArray = ArrayUtils.toObjec ...
  • 这里不需要涉及String。 只需复制到一个比输入数组短一个char的新数组。 用于此任务的方法是Arrays.copyOf 。 输出错误的原因是因为Java中的字符串与null终止符无关。 您的第一行代码创建一个字符串,其最后一个字符是空字符。 回复您更新的问题 如果你在null-char后面有垃圾,你可以使用new String(inputArray) ,然后找到带有String.indexOf('\0')的null-char,并在String.substring操作中使用它来删除不需要的部分。 但是, ...
  • 尝试使用String.trim() trimming String的尾随空格。 做就是了 : - char[] anotherWord = new char[5]; String sAnotherWord = new String(anotherWord); sAnotherWord = sAnotherWord.trim(); 现在, 空间将被删除。 编辑1 :正如spencer.sm在他的回答中提到的那样 ,您的第二个打印语句错误,因为它打印sWord.length()而不是sAnotherWord. ...
  • 当将数组中的字符提升为int以增加4 ,它们将采用基础Unicode值,其中的ASCII值是子集。 数字0-9分别由代码48-57表示。 字符'1'到'5'是49-53,然后你加4并得到53-57。 添加后,将总和转换回char以便print可以将其解释为char 。 System.out.print( (char) (k+4)); 输出: 56789 The characters in the array, when promoted to int for the addition of 4, tak ...
  • 简单的一个班轮将是: s.each_char.map(&:to_i) #=> [2, 3, 5, 3, 4] 如果你想要它是错误显式的,如果字符串不包含整数,你可以这样做: s.each_char.map { |c| Integer(c) } 这会引发ArgumentError: invalid value for Integer():如果你的字符串包含除整数以外的其他字符。 否则,对于.to_i您会看到字符为零。 A simple one liner would be: s.each_char.map ...
  • nArray[i]是一个char ; '\n'常数也是如此。 字符是无符号整数类型,因此字符以与所有整数相同的方式添加在一起 - 数字。 当一个加法发生时,你最终得到一个int ,而不是一个char ,所以调用println会产生一个数字结果。 删除+ '\n'将解决问题。 你会从println得到一个换行符,所以所有的字符都会出现在一行中。 演示。 nArray[i] is a char; so is the '\n' constant. Character is an unsigned integral ...
  • 我强烈建议你使用一个支持json的库来解析你的String 。 但是,只是为了好玩,请看下面的代码,只需使用String方法即可完成所需的操作: String s = "{{\"2D\", \"array\"}, {\"represented\", \"in a string\"}}"; s = s.replace("{", ""); String[] s0 = s.split("},\\s"); int length = s0.length; String[][] a = new String[lengt ...
  • 您可以使用ASCII值。 a有97 , b有98等等。 private int printSum(String original){ int sum = 0; if(original!=null){ char[] arr = original.toLowerCase().toCharArray(); for(int x :arr){ sum+= (x-96); } } return sum; } You ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)