简体   繁体   中英

Should url of Ajax's $.post match url in the web.xml

I am trying to send data from js to a servlet.

my js is in webapp\\secure folder while the servlet s in java\\com\\ servlet folder.

I read for sending data using ajax I use

$.post("someservletname", {cityName:"hello"});

In the web.xml

       <servlet>
            <servlet-name>someservletname</servlet-name>
            <servlet-class>java.com.someservletname</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>someservletname</servlet-name>
            <url-pattern>/someservletname</url-pattern>
        </servlet-mapping>

But when i put a simple sysout.print statement I do not see anything. How do i make sure that the mapping worked properly.Should i give the complete url in the post function call?

Ensure you put in the URL:

  • context path of your web application

Regards Philippe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM