tomcat - getting error when making a post request in ionic angular -
i new ionic3 , jaxrs guide me in correct way learn
@post @path("example1") @consumes(mediatype.application_json) @produces(mediatype.application_json) public list<dairydto> gettodaydairyforparents(employeedto employee) { emplist = employeedao.getrecords(employee.getname()); return emplist ; } this working fine in postman
but when made post request
let employee = new urlsearchparams(); employee.set('name', "ram"); this.http.post('http://localhost:8080/sms/webapi/test/example1', employee, { headers: headers }).map(res => res.json()) .subscribe(data => { // we've got raw data, generate core schedule data // , save data later reference this.data = data; resolve(this.data); }); getting errors xmlhttprequest cannot load localhost:8080/restexample/webapi/test/example1. response preflight request doesn't pass access control check: no 'access-control-allow-origin' header present on requested resource. origin localhost:8100' therefore not allowed access. response had http status code 403.
filters used in tomcat
<filter> <filter-name>corsfilter</filter-name> <filter-class>org.apache.catalina.filters.corsfilter</filter-class> </filter> <filter-mapping> <filter-name>corsfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
you trying communicate http://localhost:8080/ using xmlhttprequest localhost:8100 not allowed default. server should trust localhost:8100 adding access-control-allow-origin response header:
access-control-allow-origin: http://localhost:8100 you should configure apache corsfilter parameters according access policy need.
Comments
Post a Comment