1212See the License for the specific language governing permissions and
1313limitations under the License.*/
1414
15- package zuo . biao . apijson .server ;
15+ package apijson . demo .server ;
1616
1717import org .springframework .boot .SpringApplication ;
1818import org .springframework .boot .autoconfigure .SpringBootApplication ;
2121import org .springframework .web .cors .UrlBasedCorsConfigurationSource ;
2222import org .springframework .web .filter .CorsFilter ;
2323
24+ import zuo .biao .apijson .server .Structure ;
25+
2426/**application
2527 * @author Lemon
2628 */
2729@ SpringBootApplication
2830public class APIJSONApplication {
2931
30- public static void main (String [] args ) {
32+ public static void main (String [] args ) throws Exception {
3133 SpringApplication .run (APIJSONApplication .class , args );
3234
3335 try {
@@ -36,35 +38,38 @@ public static void main(String[] args) {
3638 e .printStackTrace ();
3739 }
3840
41+ // Structure.init();
42+
3943 try {
4044 Structure .test ();
4145 } catch (Exception e ) {
4246 e .printStackTrace ();
4347 }
4448 }
45-
46-
4749
48-
49- /**
50- * 跨域过滤器
51- * @return
52- */
53- @ Bean
54- public CorsFilter corsFilter () {
55- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource ();
56- source .registerCorsConfiguration ("/**" , buildConfig ()); // 4
57- return new CorsFilter (source );
58- }
59- /**CORS跨域配置
60- * @return
61- */
50+
51+
52+ //支持JavaScript跨域请求<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
53+ /**
54+ * 跨域过滤器
55+ * @return
56+ */
57+ @ Bean
58+ public CorsFilter corsFilter () {
59+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource ();
60+ source .registerCorsConfiguration ("/**" , buildConfig ()); // 4
61+ return new CorsFilter (source );
62+ }
63+ /**CORS跨域配置
64+ * @return
65+ */
6266 private CorsConfiguration buildConfig () {
63- CorsConfiguration corsConfiguration = new CorsConfiguration ();
64- corsConfiguration .addAllowedOrigin ("*" );
65- corsConfiguration .addAllowedHeader ("*" );
66- corsConfiguration .addAllowedMethod ("*" );
67- return corsConfiguration ;
68- }
69-
67+ CorsConfiguration corsConfiguration = new CorsConfiguration ();
68+ corsConfiguration .addAllowedOrigin ("*" );
69+ corsConfiguration .addAllowedHeader ("*" );
70+ corsConfiguration .addAllowedMethod ("*" );
71+ return corsConfiguration ;
72+ }
73+ //支持JavaScript跨域请求 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
74+
7075}
0 commit comments