我应该如何在myscript.js中编写url来在服务器上找到servlet BeerSelect?我已多次尝试但失败了。
myscripts.js:
var url= "../SelectBeer.do?ImageID=" + escape(itemName); // How can I write the url correctly?
的index.html:
<html>
<head>
<script src="scripts/myscripts.js" type="text/javascript"></script>
</head>
的web.xml:
<servlet>
<servlet-name> Ch3 Beer </servlet-name>
<servlet-class>com.example.BeerSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> Ch3 Beer </servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
答案 0 :(得分:0)
你试过吗
var url= "SelectBeer.do?ImageID=" + encodeURIComponent(itemName);