Browse Source

修改跨域的问题

master
djz8236 2 years ago
parent
commit
b0f7b38598
  1. 17
      warehousing-system/project/wh-manage/src/main/java/com/wh/config/WebMvcConfig.java
  2. 1
      warehousing-system/project/wh-manage/src/main/java/com/wh/controller/brandinfo/BrandInfoRest.java
  3. 1
      warehousing-system/project/wh-manage/src/main/java/com/wh/controller/dictcommon/DictCommonRest.java
  4. 1
      warehousing-system/project/wh-manage/src/main/java/com/wh/controller/dicttype/DictTypeRest.java
  5. 1
      warehousing-system/project/wh-manage/src/main/java/com/wh/controller/entinfo/EntInfoRest.java
  6. 1
      warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouse/ShStorehouseRest.java
  7. 1
      warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouseattachment/ShStorehouseAttachmentRest.java
  8. 1
      warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouseattribute/ShStorehouseAttributeRest.java
  9. 2
      warehousing-system/project_web/src/components/initial_value/storehouse.vue

17
warehousing-system/project/wh-manage/src/main/java/com/wh/config/WebMvcConfig.java

@ -2,8 +2,10 @@ package com.wh.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Value("${yuan.file.root.path}")
@ -16,4 +18,19 @@ public class WebMvcConfig implements WebMvcConfigurer {
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/archive/**").addResourceLocations("file:" + fileRootPath);
}
@Override
public void addCorsMappings(CorsRegistry registry){
//设置允许跨域的路径
registry.addMapping ("/**")
//设置允许跨域请求的域名
.allowedOrigins("*")
//是否允许证书
.allowCredentials (true)
//设置允许的方法
.allowedMethods ("GET","POST")
//设置允许的header属性
.allowedHeaders ("*")
//允许跨域时间
.maxAge (3600);
}
}

1
warehousing-system/project/wh-manage/src/main/java/com/wh/controller/brandinfo/BrandInfoRest.java

@ -52,6 +52,7 @@ import org.springframework.web.bind.annotation.*;
* @version 1.0
* @since 1.0
*/
@CrossOrigin
@Api(tags = "品牌信息")
@RestController("com.supervise.biz.brandinfo.BrandInfoRest")
@RequestMapping("v1/brandinfo")

1
warehousing-system/project/wh-manage/src/main/java/com/wh/controller/dictcommon/DictCommonRest.java

@ -49,6 +49,7 @@ import org.springframework.web.bind.annotation.*;
* @version 1.0
* @since 1.0
*/
@CrossOrigin
@Api(tags = "数据字典——数据项")
@RestController("com.wh.controller.dictcommon.DictCommonRest")
@RequestMapping("v1/dictcommon")

1
warehousing-system/project/wh-manage/src/main/java/com/wh/controller/dicttype/DictTypeRest.java

@ -51,6 +51,7 @@ import org.springframework.web.bind.annotation.*;
* @version 1.0
* @since 1.0
*/
@CrossOrigin
@Api(tags = "数据字典——数据类型")
@RestController("com.wh.controller.dicttype.DictTypeRest")
@RequestMapping("v1/dicttype")

1
warehousing-system/project/wh-manage/src/main/java/com/wh/controller/entinfo/EntInfoRest.java

@ -55,6 +55,7 @@ import java.util.List;
* @version 1.0
* @since 1.0
*/
@CrossOrigin
@Api(tags = "客户信息")
@RestController("com.wh.biz.entinfo.EntInfoRest")
@RequestMapping("v1/entinfo")

1
warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouse/ShStorehouseRest.java

@ -55,6 +55,7 @@ import java.util.List;
* @version 1.0
* @since 1.0
*/
@CrossOrigin
@Api(tags = "库房信息表")
@RestController("com.wh.biz.shstorehouse.ShStorehouseRest")
@RequestMapping("v1/shstorehouse")

1
warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouseattachment/ShStorehouseAttachmentRest.java

@ -53,6 +53,7 @@ import java.util.List;
* @version 1.0
* @since 1.0
*/
@CrossOrigin
@Api(tags = "库房附件,如合同,图片等")
@RestController("com.wh.biz.shstorehouseattachment.ShStorehouseAttachmentRest")
@RequestMapping("v1/shstorehouseattachment")

1
warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouseattribute/ShStorehouseAttributeRest.java

@ -53,6 +53,7 @@ import java.util.List;
* @version 1.0
* @since 1.0
*/
@CrossOrigin
@Api(tags = "库房性质")
@RestController("com.wh.biz.shstorehouseattribute.ShStorehouseAttributeRest")
@RequestMapping("v1/shstorehouseattribute")

2
warehousing-system/project_web/src/components/initial_value/storehouse.vue

@ -441,7 +441,7 @@ export default {
"/v1/shstorehouse/listPage",
{ params: this.queryInfo }
);
if (result.status !== 200) return this.$message.error("获取列表失败");
if (result.code !== 200) return this.$message.error("获取列表失败");
this.total = result.data.total;
this.storehouseList = result.data.rows;

Loading…
Cancel
Save