After the maven+ssm (spring+springmvc+mybatis) project is added to easyui, it cannot be correctly imported into easyui related files.

First describe the problem I encountered:

    Create a new common web project project1 and a maven web project project2 (ssm framework is introduced), the webcontent of project1 is shown in Figure 1, the webapp of project2 is shown in Figure 2, and the content of its webapp is copied under the webContent of project1 .

   

       Figure 1 project1                                                               

      

          Figure 2 project2

       ps:   webapp is a project managed by maven, and WebContent is an ordinary dynamic web project. There is no difference in essence.

Accessing Index.jsp under project1 can be accessed normally, but Index.jsp under project2 cannot find the files under easyui.

The solution is solved by referring to this URL: Click the open link . The specific solutions are as follows:

Add the following code to web.xml (this code does not seem to have much effect before and after springMvc):

         <servlet-mapping>
		<servlet-name>default</servlet-name>
		<url-pattern>*.js</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>default</servlet-name>
		<url-pattern>*.css</url-pattern>
	</servlet-mapping>

        At the same time, make the following modifications to the index.jsp file in project2

         before fixing:

<script type="text/javascript" src="jquery-easyui-1.5.4.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.5.4.2/jquery.easyui.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.5.4.2/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="jquery-easyui-1.5.4.2/themes/default/easyui.css" type="text/css" />
<link rel="stylesheet" href="jquery-easyui-1.5.4.2/themes/icon.css" type="text/css" />
        After modification:
<%  
    String path = request.getContextPath();  
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
 %>  
<base href="<%=basePath%>">  
<script type="text/javascript" src="<%=basePath%>jquery-easyui-1.5.4.2/jquery.min.js"></script>  
<script type="text/javascript" src="<%=basePath%>jquery-easyui-1.5.4.2/jquery.easyui.min.js"></script>  
<script type="text/javascript" src="<%=basePath%>jquery-easyui-1.5.4.2/locale/easyui-lang-zh_CN.js"></script>  
<link rel="stylesheet" type="text/css" href="<%=basePath%>jquery-easyui-1.5.4.2/themes/icon.css">  
<link rel="stylesheet" type="text/css" href="<%=basePath%>jquery-easyui-1.5.4.2/themes/default/easyui.css">  

    in: 

request.getContextPath()//Get the project name
request.getScheme() //Returns the protocol used by the current link; for example, general applications return http; SSL returns https;
request.getServerName(): // is to get the domain name of your website, if it is local, it is localhost //request.getServerPort(): is the port number

 In the end, the problem was solved, but the reason why it was solved in this way is not well understood. For a Cheng Yuan who is ready to work soon, the road is still very long. I'll update the blog again when I figure out what I'm asking for this solution.




    

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324483479&siteId=291194637