http - Tomcat "Access-Control-Allow-Origin" and JavaScript -


I have a big problem with my server on Corrosion on my server local server is running on a tomake applied by me The server has some restroom resources. Example:

  @ path ("user") public class UserService {@GET @Path ("/ {username} / {password}" @ product ( "Text / plain") public string check login parameter (@PathParam ("username") string username, @ pathperm ("password") string passer E) {string tempUserName = ""; String tempPassword = ""; String boole = ""; EntityManager em = createEntityManager (); Try {user user = (user) em.createQuery (select "and user u ou u.username = '" + username + "' and u.password = '" + + password "" ") GetSingleResult (); TempUserName = User.getUsername (); TempPassword = user.getPassword ();} hold (exception E) {} if (userName.Angles (TemuSearyerName) & amp; Username.ISITIT () & password ASLES (temppassword) & amp; ; Password! ISITIT (); {BIL = "true";} Else {bool = "false";} return bool;}}  

Ressource is working now I have a separate website To javascript When I try to do this, I get an error message:

  XMLHttpRequest http: // localhost: 8080 / RSAppStore / user / Can not load poc / poc. There is no 'access-control-permission-generation' header on the requested resource Origin 'blank' is not allowed for entry  

I know That I have added my server to the permission for the CORS. I do it like this Class I:

web.xml:

  & lt; Filter & gt; & Lt; Filter-name & gt; CORS & lt; / Filter-name & gt; & Lt; Filter range & gt; Com.thetransactioncompany.cors.CORSFilter & lt; / Filter range & gt; & Lt; Init-param & gt; & Lt; Ultimate Name & gt; Cors.allowOrigin & lt; / Lastname & gt; & Lt; Ultimate Price & gt; * & Lt; / Super-valued & gt; & Lt; / Init-param & gt; & Lt; Init-param & gt; & Lt; Ultimate Name & gt; Cors.supportedMethods & lt; / Lastname & gt; & Lt; Ultimate Price & gt; GET, POST, HEAD, PUT, DELETE & lt; / Param-value & gt; & Lt; / Init-param & gt; & Lt; Init-param & gt; & Lt; Ultimate Name & gt; Cors.supportedHeaders & lt; / Lastname & gt; & Lt; Ultimate Price & gt; * & Lt; / Super-valued & gt; & Lt; / Init-param & gt; & Lt; Init-param & gt; & Lt; Ultimate Name & gt; Cors.exposedHeaders & lt; / Lastname & gt; & Lt; Ultimate Price & gt; Set cookies & lt; / Super-valued & gt; & Lt; / Init-param & gt; & Lt; Init-param & gt; & Lt; Ultimate Name & gt; Cors.supportsCredentials & lt; / Lastname & gt; & Lt; Ultimate Price & gt; True & lt; / Super-valued & gt; & Lt; / Init-param & gt; & Lt; / Filter & gt; & Lt; Filter-mapping & gt; & Lt; Filter-name & gt; CORS & lt; / Filter-name & gt; & Lt; URL pattern & gt; / * & Lt; / URL pattern & gt; & Lt; / Filter-mapping & gt;  

To access JavaScript:

  & lt; Script type = "text / javascript" & gt; $ (Function () {$ .ajax ({type: "GET", crossderman: true, url: "http: // robosmart-appstore: robosmart @ localhost: 8080 / rsappstore / user / poc / poc", contentType: " Text / plain ", success: function (string) {console.log (string);}, error: function () {console.log (" err ");}});}); & Lt; / Script & gt;  

In addition I have added these 2 jars.

  cors-filter-1.9.2.jar java-property-utils-1.9.jar  

I have read so many examples and explanations on the Internet, But nothing is working and I do not know what I am doing.

I'm just talking about Tomcat and angular. I am successful in passing Corse with JS.

There is something you might need to configure:

  1. Change cors.supportedHeaders to:

      & lt; Init-param & gt; & Lt; Ultimate Name & gt; Cors.supportedHeaders & lt; / Lastname & gt; & Lt; Ultimate Price & gt; Accept, originate, with X-requested, content-type, last-modified & lt; / Param-value & gt; & Lt; / Init-param & gt;  
  2. / Strong> on:

      contentType: "application / x-www-form-urlencoded; charset = utf-8"  

Try it man


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -