java cms 拖拽布局_cms-框架搭建

本文详细介绍了如何使用Java进行CMS框架搭建,包括web.xml中的配置,如Shiro权限过滤器、字符编码过滤器,以及Spring监听器和servlet。此外,还涉及了applicationContext.xml的配置,如数据源、SessionFactory、事务管理器和Service包的扫描。同时,文中还提到了MyBatis映射文件、MyBatis配置文件、Spring MVC配置以及Shiro Realm的创建。通过这些配置,实现了CMS框架的基础结构,并具备拖拽布局功能。
摘要由CSDN通过智能技术生成

1.web.xml中的配置,在配置中主要有:

1.1.过滤器:

1.1.1:shiro权限过滤器

1.1.2:字符编码过滤器

1.2.监听器:

1.2.1:spring监听器

1.3.servlet

1.3.1:springMvc的servlet

aa

index.jsp

shiroFilter

org.springframework.web.filter.DelegatingFilterProxy

targetFilterLifecycle

true

shiroFilter

/*

contextConfigLocation

classpath:applicationContext.xml

encodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

encodingFilter

/*

org.springframework.web.context.ContextLoaderListener

springMVC

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:spring-mvc.xml

1

springMVC

*.do

springMVC

*.html

---------------------------------------------------------------------------------------------------------------------------------------------------------------

2.配置application.xml

2.1:配置数据源:

2.2:配置sessionFactory

2.2.1:配置对mappers包下面.xml文件的扫描

2.2.2:配置对mybatis-config.xml配置文件的加载

2.3:配置dao包的扫描

2.4:配置shiro的ralm相关:

2.4.1:配置realm

2.4.2:配置securityManager

2.4.3:配置shiroFilter

2.4.4:配置lifecycle

2.4.5:配置shiro注解

2.5:配置事务管理器

2.6:配置通知

2.7:配置事务传播属性

2.8:配置切面

2.9:配置service包的扫描

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:p="http://www.springframework.org/schema/p"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:jee="http://www.springframework.org/schema/jee"

xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd

http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

class="com.alibaba.druid.pool.DruidDataSource">

class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

/login=anon

/admin/**=authc

expression="execution(* com.open1111.service.*.*(..))" />

-------------------------------------------------------------------------------------------------------------------------------------------------------------

3.配置mybatis映射文件

/p>

PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

-----------------------------------------------------------------------------------------------------------------------------------------------------------

4.配置mybaties配置文件

/p>

PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

5配置springMvc

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:p="http://www.springframework.org/schema/p"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:jee="http://www.springframework.org/schema/jee"

xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd

http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd

http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

--------------------------------------------------------------------------------------------------

6.创建shiro的real

package com.open1111.realm;

import org.apache.shiro.authc.AuthenticationException;

import org.apache.shiro.authc.AuthenticationInfo;

import org.apache.shiro.authc.AuthenticationToken;

import org.apache.shiro.authz.AuthorizationInfo;

import org.apache.shiro.realm.AuthorizingRealm;

import org.apache.shiro.subject.PrincipalCollection;

/**

* 自定义Reaml

* @author user

*

*/

public class MyRealm extends AuthorizingRealm{

@Override

protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {

// TODO Auto-generated method stub

return null;

}

@Override

protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {

// TODO Auto-generated method stub

return null;

}

}

7.创建实体类:

package com.open1111.entity;

/**

* 管理员实体

* @author user

*

*/

public class Manager {

private Integer id; // 编号

private String userName; // 用户名

private String password; // 密码

public Integer getId() {

return id;

}

public void setId(Integer id) {

this.id = id;

}

public String getUserName() {

return userName;

}

public void setUserName(String userName) {

this.userName = userName;

}

public String getPassword() {

return password;

}

public void setPassword(String password) {

this.password = password;

}

}

-------------------------------------------------------------------------------------------------------------------

8.创建dao的接口层

package com.open1111.dao;

/**

* 管理员Dao接口

* @author user

*

*/

public interface ManagerDao {

}

---------------------------------------------------------------------------------------------------------------------

9.创建service

9.1创建Service接口:

package com.open1111.service;

/**

* 管理员Service接口

* @author user

*

*/

public interface ManagerService {

}

9.2创建service的实现:

package com.open1111.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.open1111.dao.ManagerDao;

import com.open1111.service.ManagerService;

/**

* 管理员Service实现类

* @author user

*

*/

@Service("managerService")

public class ManagerServiceImpl implements ManagerService{

@Resource

private ManagerDao managerDao;

}

----------------------------------------------------------------------------------------------------------

创建controller

package com.open1111.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import com.open1111.service.ManagerService;

/**

* 管理员Controller层

* @author user

*

*/

@Controller

@RequestMapping("/manager2")

public class ManagerController {

@Resource

private ManagerService managerService;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值