How to handle CORS using JAX-RS with Jersey

后端 未结 5 690
北荒
北荒 2020-11-22 02:01

I\'m developing a java script client application, in server-side I need to handle CORS, all the services I had written in JAX-RS with JERSEY. My code:

@Cross         


        
5条回答
  •  萌比男神i
    2020-11-22 02:37

    To solve this for my project I used Micheal's answer and arrived at this:

        
            org.apache.tomcat.maven
            tomcat7-maven-plugin
            2.2
            
                
                    run-embedded
                    
                        run
                    
                    pre-integration-test
                    
                        ${maven.tomcat.port}
                        true
                        ${project.basedir}/tomcat/context.xml
                        
                        ${maven.tomcat.web-xml.file}
                    
                
            
        
    

    The CORS filter being the basic example filter from the tomcat site.

    Edit:
    The maven.tomcat.web-xml.file variable is a pom defined property for the project and it contains the path to the web.xml file (located within my project)

提交回复
热议问题