我使用Ubuntu并在其上安装了Curl.我想用Curl测试我的Spring REST应用程序.我在Java端编写了我的POST代码.但是,我想用Curl测试它.我正在尝试发布JSON数据.示例数据如下:
{"value":"30","type":"Tip 3","targetModule":"Target 3","configurationGroup":null,"name":"Configuration Deneme 3","description":null,"identity":"Configuration Deneme 3","version":0,"systemId":3,"active":true}
Run Code Online (Sandbox Code Playgroud)
我用这个命令:
curl -i \
-H "Accept: application/json" \
-H "X-HTTP-Method-Override: PUT" \
-X POST -d "value":"30","type":"Tip 3","targetModule":"Target 3","configurationGroup":null,"name":"Configuration Deneme 3","description":null,"identity":"Configuration Deneme 3","version":0,"systemId":3,"active":true \
http://localhost:8080/xx/xxx/xxxx
Run Code Online (Sandbox Code Playgroud)
它返回此错误:
HTTP/1.1 415 Unsupported Media Type
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=utf-8
Content-Length: 1051
Date: Wed, 24 Aug 2011 08:50:17 GMT
Run Code Online (Sandbox Code Playgroud)
错误描述如下:
服务器拒绝此请求,因为请求实体的格式不受所请求方法()的请求资源支持.
Tomcat日志:"POST/ui/webapp/conf/clear HTTP/1.1"415 1051
关于Curl命令的正确格式的任何想法?
编辑:
这是我的Java端PUT代码(我测试过GET和DELETE,它们有效)
@RequestMapping(method = RequestMethod.PUT)
public Configuration updateConfiguration(HttpServletResponse response, @RequestBody Configuration configuration) { //consider @Valid tag
configuration.setName("PUT worked");
//todo If error occurs …Run Code Online (Sandbox Code Playgroud) 如何在PHP中检测使用了哪种请求类型(GET,POST,PUT或DELETE)?
我想转换这些类型的值,'3','2.34','0.234343',等多项.我们可以在JavaScript中使用Number(),但PHP中是否有类似的方法?
Input Output
'2' 2
'2.34' 2.34
'0.3454545' 0.3454545
Run Code Online (Sandbox Code Playgroud) 当我尝试运行时a2enmod php7.0- 我收到消息"考虑到php7的冲突php5".
重启apache后 - apache无法启动.
怎么解决这个?
也许一些已经启用的模块链接到php5?
参数:Ubuntu Wily,Apache 2.4.18,PHP 7.0.4(仅适用于cli)
我正在我的项目中使用Vuetifyjs库.我想向我的组件添加转换 - 但是没有关于如何启动转换的文档.
例如,我想在屏幕上添加一些转换到我的卡的外观.
<v-card transition="v-slide-y-transition">...</v-card>
Run Code Online (Sandbox Code Playgroud)
如何开始转型?
标题说.我想用它$_ENV来将一些变量附加到当前环境中.
$current_env = get_all_env_vars_magically();
$env = array_merge($current_env, $new_vars);
$ph = proc_open($command, array(1 => array('pipe', 'w')),
$pipes, dirname(__FILE__), $env);
Run Code Online (Sandbox Code Playgroud)
编辑:$_SERVER默认为空/未填充.$_ENV包含的不仅仅是env vars.
在Laravel我使用Faker.(fzaninotto/Faker)
无法更改生成的文本的区域设置(语言).
我的代码:
use Faker\Factory as Faker;
class MySeeder extends Seeder {
public function run() {
$faker = Faker::create('ru_RU');
$randomSentence = $faker->sentence();
...
}
}
Run Code Online (Sandbox Code Playgroud)
但是,结果$randomSentence包含来自默认语言环境('en_EN')的生成文本.
PS Faker已更新.文件夹'\ vendor\fzaninotto\faker\src\Faker\Provider\ru_RU'包含Text.php
php ×8
casting ×2
apache ×1
class ×1
components ×1
curl ×1
datetime ×1
faker ×1
http ×1
http-headers ×1
integer ×1
javascript ×1
json ×1
laravel ×1
localization ×1
oop ×1
request ×1
rest ×1
scope ×1
spring-mvc ×1
string ×1
ubuntu ×1
vuetify.js ×1