新建项目

This commit is contained in:
2023-05-25 11:05:36 +08:00
parent ef9223bc1c
commit dc81a17b9c
7 changed files with 289 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
/*
* @Author: Kane
* @Date: 2023-05-25 11:02:53
* @LastEditors: Kane
* @FilePath: /NewCitizenQueryResult/src/main/java/com/cpic/xim/web/filters/CrosFilter.java
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
/*
* @Author: Kane
* @Date: 2023-02-28 22:52:32
* @LastEditors: Kane
* @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/web/filters/cros/CrosFilter.java
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
package com.cpic.xim.web.filters.cros;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpMethod;
public class CrosFilter implements Filter
{
@Override
public void doFilter( ServletRequest req, ServletResponse resp, FilterChain chain )
throws ServletException, IOException
{
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) resp;
String method = request.getMethod();
String originHeader = request.getHeader( "Origin" );
System.out.println( "收到" + method + "请求,来自" + originHeader);
// 如果是Options请求
if ( method.equals(HttpMethod.OPTIONS.toString()) )
{
originHeader = "*";
}
response.setHeader( "Access-Control-Allow-Origin", originHeader );
response.setHeader( "Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT" );
response.setHeader( "Access-Control-Max-Age", "0" );
response.setHeader( "Access-Control-Allow-Headers",
"Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,userId,token" );
response.setHeader( "Access-Control-Allow-Credentials", "true" );
response.setHeader( "XDomainRequestAllowed", "1" );
response.setHeader( "XDomainRequestAllowed", "1" );
chain.doFilter( request, response );
}
}

View File

@@ -0,0 +1,35 @@
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/account/p13_account_check</url-pattern>
</servlet-mapping>
<filter>
<filter-name>CrosFilter</filter-name>
<filter-class>com.cpic.xim.web.filters.CrosFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CrosFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
</web-app>

View File

@@ -0,0 +1,37 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<context:component-scan base-package="com.cpic.xim" />
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<!-- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property
name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean> -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8" />
<property name="maxUploadSize" value="-1" />
</bean>
</beans>

View File

@@ -0,0 +1,5 @@
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>

View File

@@ -0,0 +1,23 @@
/*
* @Author: Kane
* @Date: 2023-05-25 10:36:14
* @LastEditors: Kane
* @FilePath: /NewCitizenQueryResult/src/test/java/com/cpic/xim/test/NewCitizenQueryResultTest.java
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
package com.cpic.xim.test;
import org.junit.Test;
public class NewCitizenQueryResultTest
{
@Test
public void testSaveQueryResult()
{
}
}