jeecms3.0.4版本 详解请求如何找到首页(转)

第一步:发送http://localhost:8080/emisstrade/ 请求

 

 

第二步:首先进入配置文件web.xml

       <context-param>

                     <param-name>contextConfigLocation</param-name>

                     <param-value>

                            /WEB-INF/config/application-context.xml

                            /WEB-INF/config/cache-context.xml

                            /WEB-INF/config/captcha-context.xml

                            /WEB-INF/config/jeecore-context.xml

                            /WEB-INF/config/jeecms-context.xml

                     </param-value>

       </context-param>

       应用范围内的初始化参数

 

 

第三步:选择页面:

       <welcome-file-list>

                     <welcome-file>index.html</welcome-file>

                     <welcome-file>index.shtml</welcome-file>

                     <welcome-file>index.jhtml</welcome-file> 走这个

 

       </welcome-file-list>

 

 

第四步:web.xml中的servlet配置拦截

       <servlet>

              <servlet-name>JeeCmsFront</servlet-name>

              <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

              <init-param>

                     <param-name>contextConfigLocation</param-name>

                     <param-value>/WEB-INF/config/jeecms-servlet-front.xml</param-value>

              </init-param>

              <load-on-startup>2</load-on-startup>

       </servlet>

       <servlet-mapping>

              <servlet-name>JeeCmsFront</servlet-name>

              <url-pattern>*.jhtml</url-pattern>

       </servlet-mapping>

 

 

第五步:找到/WEB-INF/config/jeecms-servlet-front.xml

       FrontContextInterceptor和FrontLocaleInterceptor拦截器

              <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">

                     <property name="interceptors">

                            <list>

                                   <ref bean="frontContextInterceptor"/>

                                   <ref bean="frontLocaleInterceptor"/>

                            </list>

                     </property>

              </bean>

              <bean id="frontContextInterceptor" class="com.jeecms.cms.web.FrontContextInterceptor"/>

              <bean id="frontLocaleInterceptor" class="com.jeecms.cms.web.FrontLocaleInterceptor"/>

      

       发送http://localhost:8080/emisstrade/ 请求时被FrontContextInterceptor拦截----CMS上下文信息拦截器。

       执行preHandle方法中---》cmsSiteMng.getListFromCache()返回站点集合---》dao.getList(true)--》String hql = "from CmsSite bean order by bean.id asc"; return getSession().createQuery(hql).setCacheable(cacheable).list();

 

       此时给站点赋值并保存到request中(CmsUtils.setSite(request, site)方法中---》request.setAttribute(SITE_KEY, site);)用户信息也是如此保存到request(CmsUtils.setUser(request,user);)

 

       然后进入FrontLocaleInterceptor拦截----前台本地化信息拦截器:

       执行preHandle方法中---》CmsUtils.getSite(request)方法中---》request.getAttribute(SITE_KEY);

       还有个方法localeResolver.setLocale(request, response, (Locale) localeEditor.getValue());

 

 

 

第六步:jeecms-servlet-front.xml里面有<import resource="jeecms-servlet-front-action.xml"/>

 

       在jeecms-servlet-front-action.xml配置文件中有

       <bean id="dynamicAct" class="com.jeecms.cms.action.front.DynamicPageAct"/>

       可以找到类DynamicPageAct,根据注解机制:

       @RequestMapping(value = "/index.jhtml", method = RequestMethod.GET)

       public String indexForWeblogic(HttpServletRequest request, ModelMap model) {//此时model为{}

              return index(request, model);//方法如下

       }

 

       @RequestMapping(value = "/", method = RequestMethod.GET)

       public String index(HttpServletRequest request, ModelMap model) {

              CmsSite site = CmsUtils.getSite(request);//获取站点信息

              FrontUtils.frontData(request, model, site);//方法如下

              //为前台模板设置公用数据里面有frontData(map, site, ser, location, startTime);给map添加数据

              return FrontUtils.getTplPath(request, site.getSolutionPath(),TPLDIR_INDEX, TPL_INDEX);

              //获得模板路径。将对模板文件名称进行本地化处理。返回路径/WEB-INF/t/cms/www/red/index/首页.html

       }

 

      

       public static void frontData(Map<String, Object> map, CmsSite site,

                     CmsUser user, String location, Long startTime) {//给map添加数据,很重要

              if (startTime != null) {

                     map.put(START_TIME, startTime);

              }

              if (user != null) {

                     map.put(USER, user);

              }

              map.put(SITE, site);

              String ctx = site.getContextPath() == null ? "" : site.getContextPath();

              map.put(BASE, ctx);

              map.put(RES_SYS, ctx + RES_PATH);

              String res = ctx + RES_PATH + "/" + site.getPath() + "/"

                            + site.getTplSolution();

              // res路径需要去除第一个字符'/'

              map.put(RES_TPL, res.substring(1));

              map.put(LOCATION, location);

       }

 

map数据例子:{(START_TIME)_start_time=1300770144531, (SITE)site=com.jeecms.cms.entity.main.CmsSite@2e3013f6, (BASE)base=/emisstrade,(RES_SYS)resSys=/emisstrade/r/cms, (RES_TPL)res=emisstrade/r/cms/www/red,(LOCATION)location=http://localhost:8080/emisstrade/}

 

 

 

       public static String getTplPath(HttpServletRequest request,

                     String solution, String dir, String name) {

              return solution + "/" + dir + "/"+ MessageResolver.getMessage(request, name) +TPL_SUFFIX;

              //MessageResolver.getMessage(request, name)获得国际化信息

       }

其他

返回首页.html后,加载并执行标签,然后再发出用户登录页面请求,在用户登录的js里有触发登录的请求

posted @ 2016-11-17 10:10  新月勾魂  阅读(673)  评论(0编辑  收藏  举报