Web. XML Direct Jump SPRINGMVC link problem

Source: Internet
Author: User


? ? ? ?

Http://localhost/SSM The default entry is the landing page, if after landing, then enter Http://localhost/SSM , you should let it go to the homepage.

We can configure user/main.do directly on the Web. xml

<?xml version= "1.0" encoding= "UTF-8"? ><web-app xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns= "Http://java.sun.com/xml/ns/javaee" xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee/http Java.sun.com/xml/ns/javaee/web-app_2_5.xsd "id=" webapp_id "version=" 2.5 "> <display-name>ssm</ display-name> <welcome-file-list> <welcome-file>user/main.do</welcome-file> </ Welcome-file-list></web-app>

The following is the interceptor configuration

package com.gj.filter;import javax.servlet.http.httpservletrequest;import  Javax.servlet.http.httpservletresponse;import org.springframework.web.servlet.handlerinterceptor;import  org.springframework.web.servlet.ModelAndView;import com.gj.model.User;public class  logininterceptor implements handlerinterceptor{//private logger logger  =  Logger.getlogger (logininterceptor.class);   private static final string[] ignore_ uri = {"/login", "WeChat", "register", "Checkusernamerepeat", "Save"}; @Overridepublic  void  Aftercompletion (httpservletrequest arg0,httpservletresponse arg1, object arg2,  EXCEPTION&NBSP;ARG3) throws exception {// todo auto-generated method stub}@ Overridepublic void posthandle (HTTPSERVLETREQUEST&NBSP;ARG0,&NBSP;HTTPSERVLETRESPONSE&NBSP;ARG1, OBJECT&NBSP;ARG2,&NBSP;MODELANDVIEW&NBSP;ARG3)  throws&nbsp exception {} @Overridepublic  boolean prehandle (httpservletrequest request,  Httpservletresponse response,object obj)  throws exception {boolean flag =  false;        string url = request.getrequesturl ( ). toString ();         system.out.println (">>>: "  +  url);        for  (String s : ignore_uri)  {            if  (Url.contains (s))   {                flag =  true;                 break;            }         }        if  (!flag)  {             User user =  (User)  request.getsession () getattribute ("CurrentUser" );            if  (User != null)              {             if (Null==user.getwechat_num_type ()  && url.indexof ( "Presave.do") >-1 && url.indexof ("user")  < 0) {                 flag = false;                 request.getsession (). SetAttribute ("Info", "true");                 response.sendredireCT (Request.getcontextpath () + "/user/presave.do");                 }             else            {             flag = true;             }                            }             else             {             Response.sendredirect (Request.getcontextpath () + "/login.jsp");             }   &nbSp;    }        return flag;}} 

If Http://localhost/SSM is found to be a 404 error, verify that it is TOMCAT7 or above if the code does not have a problem.

Summary sentence: If your environment is SPRINGMVC, you want to configure the Web. XML Direct jump SPRINGMVC link, tomcat must be more than 7

Web. XML Direct Jump SPRINGMVC link problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.