As we know, direct access to the JSP EL expression in js is unable to obtain, if you want to get ${pageContext. Request. ContextPath} value, we can use the following two ways:
1, in the ${pageContext. Request. ContextPath} with single quotes, this is the most simple way
2. Create a form with type= “hidden”, for example:
<input name="rootUrl" id="rootUrl" type="hidden" value="${pageContext.request.contextPath}"/>
Then get the value of the form through the JS action:
//Get the project root path
var rootUrl = "";
$(function () {
rootUrl = $("#rootUrl").val();
})
Read More:
- Solution to build error in Vue project (error in static/JS)/vendor.xxxxx.js from UglifyJs)
- [Solved] node.js request Error: Error: unable to verify the first certificate
- Trigger http request when tab page is closed in angular2+ project
- request.js?b775:101 Uncaught (in promise) Error: Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Long’;
- [Solved] Nuxt Import qrcodejs2.js / QRCode.js Error: document is not defined
- Solution to some map files in JS folder after Vue packaging (remove the map. JS file)
- The solution to the failure of HTML introducing external JS
- Vue Project Error: Proxy error: Could not proxy request [How to Solve]
- [Solved] webpack Package Error: ERROR in multi ./src/main.js ./dist/bundle.js Module not found: Error: Can‘t resolv
- If the request parameter is formdata, use the Ajax operation
- [Solved] node.js Upload Files Error: Multipart: boundary not found multer
- [vue/no-multiple-template-root] The template root requires exactly one element.
- Interface request error 504 gateway time out [How to Solve]
- Vue3 Error: [vue/no-multiple-template-root] The template root requires exactly one element
- [Solution] VUE.js Load a local image with parameters in the script
- JS bug Log Uncaught TypeError: Cannot read property ‘previoustSibling‘ of null
- Please transfer a valid prop path to form item
- [Solved] Element form method resetfields() error: vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of undefined (reading ‘indexOf’)
- Difference between contenttype and datatype in Ajax request of jquery
- [Vue error] the solution to the template root requires exactly one element error reporting