我有网络服务URL,它工作正常.它提供了JSON数据.当我使用HttpURLConnection时InputStream,我收到一个错误.喜欢
java.io.IOException:Connection上的意外流结束{comenius-api.sabacloud.com:443,proxy = DIRECT hostAddress = 12.130.57.1 cipherSuite = TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 protocol = http/1.1}(recycle count = 0)
try{
URL url = new URL("https://comenius-api.sabacloud.com/v1/people/username="+username+":(internalWorkHistory)?type=internal&SabaCertificate="+ certificate);
HttpURLConnection con = (HttpURLConnection)url.openConnection();
InputStream ist = con.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(ist));
while((singleLine = reader.readLine())!= null){
data = data + singleLine;
Log.e("Response", data);
}
}catch(Exception e)
{
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
怎么解决这个问题?
嗨,这是我第一次用javascript和react-native开发应用程序,这是一个noob问题.如何_getData在__onRegionChangeComplete函数中调用函数?我试过this._getData()它
错误:undefined不是函数(evaluation'this._getData()')').
var React = require('react-native');
var {
StyleSheet,
Text,
View,
Image,
MapView,
Component,
} = React;
class Map extends Component {
render() {
return (
<View style={styles.container}>
<MapView style={styles.map}
showsUserLocation={true}
onRegionChangeComplete={this._onRegionChangeComplete}
/>
</View>
);
}
_onRegionChangeComplete(region)
{
}
_getData()
{
}
}
var styles = StyleSheet.create({
container:{
flex: 1
},
map: {
flex: 1,
},
image: {
width: 64,
height: 64
}
});
module.exports = Map;
Run Code Online (Sandbox Code Playgroud) 我正在使用Robin Herbot 的 inputmask jquery 插件,我得到了预期的输出,但我希望它带有逗号,即 12,345.67 和 2 个小数。
$('#curreny').inputmask({'mask':"9{0,10}[.9{0,2}]", greedy: false});
Run Code Online (Sandbox Code Playgroud) 我有一个输入,其中包含8个项目的下拉列表.根据用户选择的选项,我想将其输入值更改为不同的字符串值.为了做到这一点,我使用一吨,如果else语句,使这个看起来很笨重,我想,如果在所有可能的凝结这一点.我有以下代码:
if (inputFive == "Corporation"){
inputFive = "534"
} else if (inputFive == "LLC"){
inputFive = "535"
} else if(inputFive == "LLP"){
inputFive = "536"
} else if(inputFive == "Partnership"){
inputFive = "537"
} else if(inputFive == "Sole Proprietorship"){
inputFive = "538"
} else if(inputFive == "Limited Partnership"){
inputFive = "539"
} else {
inputFive = "540"
}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,这看起来有点老派,我想看看是否有更好/更简单的方法来实现这一点.只是想尽可能地压缩这段代码.我相信他们可能是通过分配键/值对象来创建字典的方法,但我不知道如何正确地执行此操作...所有选项/提示将不胜感激!
javascript ×3
android ×1
conditional ×1
dictionary ×1
if-statement ×1
inputstream ×1
jquery ×1
react-native ×1
rest ×1