Rose框架搭建

[size=xx-large][color=orange][b]Rose框架搭建[/b][/color][/size]

[b][size=medium][color=red]一.配置文件[/color][/size][/b]:

1.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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
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>011_RoseTools</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!--1.上下文参数和配置:系统访问名|log4j日志文件|配置rosePortal线程池-->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.011_RoseTools</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<context-param>
<param-name>portalExecutorCorePoolSize</param-name>
<param-value>200</param-value>
</context-param>

<!--2.监听器:log4j配置 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<!--3.过滤器:编码过滤|异常过滤|登陆Cookies过滤|Rose系统过滤 -->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter>
<filter-name>exceptionFilter</filter-name>
<filter-class>com.momo.filter.ExceptionFilter</filter-class>
</filter>
<filter>
<filter-name>CookiesFilter</filter-name>
<filter-class>com.momo.filter.CookiesFilter</filter-class>
</filter>
<filter>
<filter-name>roseFilter</filter-name>
<filter-class>net.paoding.rose.RoseFilter</filter-class>
</filter>
<!--过滤器映射:注意rose过滤器需放在最后 -->
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>exceptionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CookiesFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>roseFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>

<!--4.服务器发生404和505错误会跳到对应页面 -->
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
<error-page>
<error-code>505</error-code>
<location>/505.html</location>
</error-page>

<!--5.session失效时间60分钟 -->
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>


2.applicationContext-interceptors.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">

<!-- 登录拦截器:Integer.MAX_VALUE -->
<bean id="base" class="com.momo.interceptors.BaseInterceptor"></bean>
<!-- 分表主题拦截:1000 -->
<bean id="theme" class="com.momo.interceptors.ThemeInterceptor"></bean>
<!-- 登录拦截器:900 -->
<bean id="loginRequired" class="com.momo.interceptors.LoginRequiredInterceptor"></bean>
<!-- 登陆DB日志记录 -->
<bean class="com.momo.interceptors.AutoLogInterceptor"></bean>

<!-- 这里列举表名,字符串数组如”t_log,t_user,t_admin" -->
<bean class="net.paoding.rose.jade.statement.ThemeInterpreter">
<property name="hashtable">
<value>
t_userinfo,
t_admin
</value>
</property>
</bean>
</beans>


[size=medium][color=red][b]二.URL访问类拦截的顺序:[/b][/color][/size]
a.http://fanya.zaifan.net
ExceptionFilter
CookiesFilter
CookiesFilter
ExceptionFilter

b.http://fanya.zaifan.net/userInfo
ExceptionFilter(编码过滤,发生异常跳到异常页)
CookiesFilter(根据请求设置Cookies)
BaseInterceptor(得到Cookies,设置Session保存系统信息)
ThemeInterceptor(得到Session,设置分表)
LoginRequiredInterceptor(检查用户是否登录,Session取不到用户信息,跳到登陆页)
UserInfoController(请求处理控制类)
AutoLogInterceptor(请求返回的页面渲染完毕时调用,DB记录用户本次操作日志)

[size=medium][color=red][b]三、加载数据字典:[/b][/color][/size]
启动服务实例化bean时,这个类会被实例化后自动调用initCateData()方法加载系统大数据

@Component
public class SystemInitData {
@PostConstruct
public void initCateData() {
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值