posts - 8,  comments - 0,  trackbacks - 0
  2017年12月4日
mysql explain时,user表主键跟引用表(comment表)关联,始终为all,原因是: user表有18万条记录,主键 `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '用户id', 而comment表的引用 `user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '评论用户id', 字符集不相同位数也不同,引起的,查询关联不能按照主键关联,始终为all级别 解决方法:把 字符集和位数调到一样即可,一下从all级别调到了eq_ref 的级别
posted @ 2017-12-04 17:16 liufx 阅读(167) | 评论 (0)编辑 收藏
  2016年12月20日
下载:
https://www.mongodb.com/download-center?jmp=nav#community

1.解压
这里写图片描述
修改文件名为mongo3.2.5,执行命令如下:
mv mongodb-linux-i686-3.2.5 mongo3.2.5

2.创建组mongoDB与用户mongoDB、文件夹data以及log
用于与组是为了便于管理MongoDB
data用于存放mongoDB数据。
log用于记录mongoDB日志。
这里写图片描述
3.指定组、用户
这里写图片描述
4.启动mongo服务命令

bin/mongod --dbpath=/usr/local/mongo-3.25/data/ --logpath=/usr/local/mongo-3.25/log/mongo.log  --journal  --storageEngine=mmapv1

注意:因为我使用的是linux32位系统的,故默认的存储引擎wiredTiger是不支持的。需要指定存储引擎。如果不指定可能会报以下错误:
这里写图片描述
开启MongoDB服务成功后,截图如下:
这里写图片描述
连接mongo服务
上面启动MongoDB之后,需要重新打开一个窗口,进行连接。
这里写图片描述
当提示如下信息,代表连接成功。
这里写图片描述
当然,也可以通过浏览器访问以下网址,查看输出结果
http://192.168.153.140:27017
这里写图片描述



初始安装的时候没有admin数据库


开启认证

修改配置文件/etc/MongoDB.conf

打开auth的注释,设置为auth = true


重启mongodb

sudo service mongodb restart


添加管理员

使用命令mongo进入命令行

创建第一个用户,该用户需要有用户管理权限

这里设置其角色为root

use admin
db.createUser({user:"admin",pwd:"password",roles:["root"]})

新增的用户在system.users中

> db.getCollectionNames()
[ "system.indexes", "system.users", "system.version" ]


第一个用户添加完成后,便需要认证才能继续添加其他用户

使用db.auth("admin", "password")认证


添加数据库用户

为其他数据库添加用户,添加用户前需要切换到该数据库

这里设置其角色为dbOwner

use testdb1

db.createUser({user: "testdb1u1", pwd: "xyz123", roles: [{ role: "dbOwner", db: "testdb1" }]})


查看用户

> use admin
switched to db admin
> db.system.users.find()
{ "_id" : "admin.admin", "user" : "admin", "db" : "admin", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "Fdh2ldIW3Aw8Cxz9Dt+96g==", "storedKey" : "zbkfj6ZQH1xwGoOg8JJ6OjtR3Cs=", "serverKey" : "yqkqHABZ64rEeq1X0htOAtUnwFU=" } }, "roles" : [ { "role" : "root", "db" : "admin" } ] }
{ "_id" : "testdb1.testdb1u1", "user" : "testdb1u1", "db" : "testdb1", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "Xxt2uET3jRtAYVigyLUydw==", "storedKey" : "yinLG61nRFzfC+3NtB5p9RR+avM=", "serverKey" : "OX/Pdft7JWJm/g0jg07q49OC4c8=" } }, "roles" : [ { "role" : "dbOwner", "db" : "testdb1" } ] }



参考地址:
http://blog.csdn.net/zahuopuboss/article/details/53635078
http://blog.csdn.net/hsd2012/article/details/51286495




posted @ 2016-12-20 16:10 liufx 阅读(12566) | 评论 (0)编辑 收藏
  2016年11月22日
一、spring-context*.xml 合并到 spring-mvc.xml 的方法
    spring-servlet.xml 中加入 <import resource="ApplicationContext.xml" />
    ApplicationContext.xml 中把其它的xml文件import进来
    web.xml 
    SpringMVC核心分发器 加入参数 <param-value>classpath:spring-mvc.xml</param-value>
    不加载    <param-value>classpath*:/spring-context*.xml</param-value>
    controller/service等都在mvc中加载
     <context:component-scan base-package="com.mweb.**.controller" />
    <context:component-scan base-package="com.mweb.**.service" />。。。。需要加载的@Component等
    加入:
     <aop:aspectj-autoproxy proxy-target-class="true" />

二、spring-context*.xml / spring-mvc.xml 分开加载扫描的方法 
web.xml 中:
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath*:/spring-context*.xml</param-value>
 </context-param>
 <listener> 
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    必须加入才行
 </listener>

 <servlet>
  <servlet-name>spring</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring-mvc.xml</param-value>
        </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>

spring-mvc.xml 中:

 <context:component-scan base-package="com.mweb.**.controller" />   扫描 controller

 <aop:aspectj-autoproxy />         aop 参考下面的也行

  1. <aop:aspectj-autoproxy proxy-target-class="true">  
  2.         <aop:include name="controllerAspect"/>     @Aspect声明的类  
  3.     </aop:aspectj-autoproxy> 


 

spring-context.xml中:
     <context:component-scan base-package="com.mweb.**.extension,
                 com.mweb.**.service,
                 com.mweb.base.aspect,
                 com.mweb.base.shiro.realm" />
 <aop:aspectj-autoproxy proxy-target-class="true" />
这样就可以了





posted @ 2016-11-22 09:44 liufx 阅读(3257) | 评论 (0)编辑 收藏
  2016年10月27日

/*多条-删除*/
function deleteBatch(){
 layer.confirm('确认要删除吗?',function(index){

   var idList = new Array(); 

   // 获得选中的ID值
   $("input[name='id']:checkbox:checked").each(function(){
    idList.push(this.value); 
   });

   $.ajax({
          type:"post",
          url:"${CONTEXT_PATH}/sys/menu/deletebatch.html",
          data: $('#form-menu').serialize(),//表单数据 
          data: {"idList":idList},
          //cache:false,
          success:function(msg){
              if(msg=="success"){
               // 延时1S刷新
               setTimeout('location.replace(location.href)', 1000);
            layer.msg('全部删除成功!',{icon:1,time:1000});
              }
              if(msg=="error"){
                  layer.msg('异常!');
              }
          }
      });
 });
}



后台controller:
 @RequiresPermissions("sys:menu:edit")
    @ResponseBody
    @RequestMapping("/deletebatch")
    public String deletebatch(@RequestParam("idList[]") List<String> objs,ModelMap modelMap, HttpServletRequest request) throws Exception {
     String retStr = "error";
     try{
   menuService.removeMulti(objs);
   retStr = "success" ;
     }catch(Exception e) {
      logger.info(e.getMessage());
     }
     return retStr;
    }

后台service:

 @CacheEvict(value="defaultCache",allEntries=true)
 public void removeMulti(List<String> objs) {
  
  BasicDBList basicDBList=new BasicDBList();
  for(String id : objs) {
   basicDBList.add(new BasicDBObject("id",id));
  }

        DBObject obj =new BasicDBObject();
        obj.put("$or", basicDBList);
        Query query=new BasicQuery(obj);

  mongoTemplate.remove(query,Menu.class);
 } 

如果不跳转,应该把ajax里面的dataType改成html ,json时返回不正确




posted @ 2016-10-27 13:22 liufx 阅读(672) | 评论 (0)编辑 收藏

 

/** ajax登录,并jquery md5 加密密码 */
function loginsubmit() {
 var salt=$("#username").val(); 
    var pwd=$("#password").val();  
    var md5Pwd=$.md5(pwd+salt);
   
    var validateCode=$("#validateCode").val();
    var rememberMe=$("#rememberMe").val();
   
 data="username="+  salt
  + "&password=" + md5Pwd
  + "&validateCode=" + validateCode
  + "&rememberMe=" + rememberMe;

 $.ajax({
     type: "POST",
     url: "loginsubmit",
     dataType:'html',
     data: data,
     contentType:"application/x-www-form-urlencoded;charset=UTF-8",
     success: function(msg){
      if(msg=="ok") {
       location.href = "index";
      }else if (msg=="errorcode"){
       alert("验证码无效!");
      }
     },
     error: function (XMLHttpRequest, textStatus, errorThrown) {
               alert(XMLHttpRequest.status);
               alert(XMLHttpRequest.readyState);
               alert(textStatus);
           }
 });
}

以上代码中url为 loginsubmit.html 去掉".html"即可提交 ,后台代码用的@ResponseBody注解


posted @ 2016-10-27 07:46 liufx 阅读(232) | 评论 (0)编辑 收藏
  2016年10月26日

<property name="unauthorizedUrl" value="/sys/unauthorized"/> 不起作用

spring-mvc.xml 中加入:
 <!-- 异常处理 -->
 <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
  <property name="exceptionMappings">
   <props>
    <prop key="org.apache.shiro.authz.UnauthorizedException">jsp/unauthorized</prop>
    <prop key="org.apache.shiro.authz.UnauthenticatedException">jsp/unauthorized</prop>
    <prop key="org.apache.shiro.authz.AuthorizationException">jsp/unauthorized</prop>           
    <prop key="java.lang.Throwable">jsp/unauthorized</prop>
   </props>
   </property>
 </bean>

如果还不能解决:可以看一下web.xml中是否有:
 <error-page>
  <error-code>400</error-code>
  <location>/WEB-INF/template/common/errorPage.jsp</location>
 </error-page>
 <error-page>
  <error-code>404</error-code>
  <location>/WEB-INF/template/common/errorPage.jsp</location>
 </error-page>
 <error-page>
  <error-code>500</error-code>
  <location>/sys/unauthorized.html</location>
 </error-page>
都屏蔽掉,应该就好了







posted @ 2016-10-26 09:40 liufx 阅读(2846) | 评论 (0)编辑 收藏
  2016年10月24日

在context.xml 中加入红色的
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

    <Resources cachingAllowed="true" cacheMaxSize="100000" />
posted @ 2016-10-24 16:06 liufx 阅读(746) | 评论 (0)编辑 收藏
  2016年8月26日
用户名密码邮件等自动填充问题的解决:
1. form 加入:autocomplete="off"属性
2. 每个password中 加入 type="text" onfocus="this.type='password'" autocomplete="off" 属性
3. password最上面加入一个不显示的password:
<input type="password" name="password1000" style="display:none;width:0;height:0;">
4. 如果email或者username中 也自动填充 ,需要在下面加入一个不显示的text,并且必须加上name属性值 如:
<input type="text" name="email1000" style="display:none;width:0;height:0;" />

<form autocomplete="off">

<input type="text" autocomplete="off" class="post" style="WIDTH: 200px" maxlength="255" size="25" name="email" value="${u.email?default("")?html}" />
<input type="text" name="email1000" style="display:none;width:0;height:0;" />

<input type="password" name="password1000" style="display:none;width:0;height:0;">
<input type="text" onfocus="this.type='password'" autocomplete="off" />
</form>

posted @ 2016-08-26 14:20 liufx 阅读(277) | 评论 (0)编辑 收藏
仅列出标题  
<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜