Failed to load resource files when matching servlet by URL pattern /

I am using NetBeans and Tomcat 7.0.4.2 and would like to change the URL of my project from localhost:8080/Servletto localhost:8080/. In web.xmlI changed the servlet url from <url-pattern>/Servlet</url-pattern>to <url-pattern>/</url-pattern>.

The problem is that I cannot upload resource files and receive errors in the browser console log:

  Failed to load resource: the server responded with a status of 404 (Not Found) (11:45:14:149 | error, network)
  at src/main/webapp/scripts/aui-min_2.0.0.js

The path to the resource files src/main/webapp/scripts, and in the JSP file I use this path

<script type="text/javascript" src="scripts/aui-min_2.0.0.js"></script>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <servlet>
        <servlet-name>Servlet</servlet-name>
        <servlet-class>socialgraphui.Servlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Servlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>
+4
source share
1 answer

url / , , . , . , .

<servlet-mapping>
    <servlet-name>Servlet</servlet-name>
    <url-pattern>/Servlet</url-pattern>
</servlet-mapping>

, index.jsp, <welcome-file-list>.

response.sendRedirect(request.getContextPath() +"/Servlet");

,

<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/aui-min_2.0.0.js"></script>
+1

All Articles