Spring @CrossOrigin注释不适用于DELETE方法。
示例代码(在Groovy中):
@CrossOrigin
@RestController
@RequestMapping('/rest')
class SpringController {
@RequestMapping(value = '/{fileName}', RequestMethod.DELETE)
void deleteFile(@PathVariable fileName) {
// logic
}
}
对于此代码,我得到例外:
XMLHttpRequest无法加载http://localhost:8080/rest/filename.txt。没有 '访问控制允许来源'标题出现在请求的上 资源。起源' http://localhost:4200'因此是不允许的 访问。响应的HTTP状态代码为404.
注意:
@CrossOrigin(methods =
[RequestMethod.GET, RequestMethod.DELETE])
没有帮助答案 0 :(得分:0)
<target name="get-core-version">
<exec executable="bash"
outputproperty="coreVersionTemp"
failonerror="true">
<arg value="-c"/>
<arg value="cat ./Core.java | grep VERSION"/>
</exec>
<echo message=""ResultadoIntermedio": ${coreVersionTemp}"/>
<!-- <propertyregex property="coreVersionTemp2" input="coreVersionTemp" regexp=""" replace=":" global="true"/> -->
<script language="javascript">
var temp = project.getProperty("coreVersionTemp");
project.setProperty("coreVersionTemp", temp.replaceAll("\"", ":"));
</script>
<echo message=""ResultadoIntermedio2": ${coreVersionTemp}"/>
<exec executable="bash"
outputproperty="coreVersion"
failonerror="true">
<arg value="-c"/>
<arg value="echo '${coreVersionTemp}' | cut -d: -f2"/>
</exec>
<echo message="Resultado: ${coreVersion}"/>
</target>
</project>