qq_38254897
K_Z-老八
2018-12-24 21:44

网上下载的项目-导入ssm小米商城的后台项目访问登录界面login的时候无法跳转到其他页面是怎么回事?

  • spring
  • tomcat
  • maven
  • eclipse

在网上下载的ssm小米商城的后台项目

1:项目没有错误,,,
2:在访问登录界面login的时候- 却无法跳转到其他页面
3:数据库不知道是不是正常
4:我的数据库设置了管理员登录:admin 密码123456
5: 写了个generatorConfig.xml

6:::新增:看到有人回复说数据库的名字没有改:
我用的是mysql 数据库名是:shop 密码是:1234
userId我不知道是要赋值什么值,,一般不是userName吗??但是这个项目中的确实userId ,,所以我也给他 赋值了数据库的用户名 “root”但是这样配置根本就没有用,,同样无法跳转页面::::
如果配置错了,,麻烦指出来,,非常感谢,,新手新手,,实力有限抱歉
求大神帮助,,,呜呜,,还是跳转不了

数据库图片:
图片说明

数据库配置图:
图片说明

按照网友提出的问题:修改数据库名和密码:
我把connectionURL 的 work_attendance也改成了shop,, 如下:

//connectionURL="jdbc:mysql://localhost:3306/work_attendance"
connectionURL="jdbc:mysql://localhost:3306/shop"
connectionURL="jdbc:mysql://localhost:3306/shop"
userId="root" password="1234">

但是还是没有用,,,依然无法跳转,,总感觉没有错误,,,不知道错在哪了。。。。,,,,大神,,大神们求帮助中

代码如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >

<!--classPathEntry:数据库的JDBC驱动 -->
 <!--  location="D:\Develop\MvnRepo\mysql\mysql-connector-java\5.1.34\mysql-connector-java-5.1.34.jar"/> -->
<classPathEntry
        location="D:\Users\lydia\workspaceSSH\shopCMS\src\main\webapp\WEB-INF\lib\mysql-connector-java-5.1.34.jar"/>

<context id="MysqlTables" targetRuntime="MyBatis3">

    <!-- 注意这里面的顺序确定的,不能随变更改 -->
    <!-- 自定义的分页插件 <plugin type="com.deppon.foss.module.helloworld.shared.PaginationPlugin"/> -->

    <!-- 可选的(0 or 1) -->
    <!-- 注释生成器 -->
    <commentGenerator>
        <!-- 是否去除自动生成的注释 true:是 : false:否 -->
        <property name="suppressAllComments" value="true"/>
    </commentGenerator>

    <!-- 必须的(1 required) -->
    <!--数据库连接的信息:驱动类、连接地址、用户名、密码 
     connectionURL="jdbc:mysql://localhost:3306/work_attendance"
    -->
    <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                    connectionURL="jdbc:mysql://localhost:3306/shop"
                    userId="root" password="1234">
    </jdbcConnection>

,,
登录界面
图片说明
每次一点击登录:
console界面就显示:

[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:845) DispatcherServlet with name 'SpringMVC' processing POST request for [/shopCMS/login/check]
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:297) Looking up handler method for path /login/check
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:302) Returning handler method [public java.lang.String com.shop.shopmanager.controller.LoginController.checkLogin(javax.servlet.http.HttpServletRequest) throws java.io.UnsupportedEncodingException,java.security.NoSuchAlgorithmException]
[DEBUG][2018-12-24 21:47:08] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248) Returning cached instance of singleton bean 'loginController'
[DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:104) Creating a new SqlSession
[DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:140) SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7738ee46] was not registered for synchronization because synchronization is not active
[DEBUG][2018-12-24 21:47:08] org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:110) Fetching JDBC Connection from DataSource
[DEBUG][2018-12-24 21:47:08] org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:86) JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@41131e6d] will not be managed by Spring
[DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Preparing: SELECT cu.user_id AS user_id4, login_name, login_password, salt, user_name, real_name, sex, age, pic_img, cu.status AS status4, email, telephone, cu.create_time AS create_time4, cu.update_time AS update_time4, cr.role_id AS role_id2, role_name, role_sign, is_system, cr.status AS status2, cr.create_time AS create_time2, cr.update_time AS update_time2, cr.remarks AS remarks2, cm.menu_id AS menu_id1, parent_id, menu_type, menu_code, menu_name, sort, href, icon, cm.status AS status1, permission, cm.create_time AS create_time1, cm.update_time AS update_time1, cm.remarks AS remarks1 FROM cms_menu cm, cms_role cr, cms_role_menu crm, cms_user cu, cms_user_role cur WHERE crm.role_id = cr.role_id AND crm.menu_id = cm.menu_id AND cur.user_id = cu.user_id AND cur.role_id = cr.role_id AND cu.login_name = ?;

[DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Parameters: admin(String)
[DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) <== Total: 73
[DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.closeSqlSession(SqlSessionUtils.java:168) Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7738ee46]
[DEBUG][2018-12-24 21:47:08] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:327) Returning JDBC Connection to DataSource
[DEBUG][2018-12-24 21:47:08] org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:569) Looked up AuthenticationInfo [admin] from doGetAuthenticationInfo
[DEBUG][2018-12-24 21:47:08] org.apache.shiro.realm.AuthenticatingRealm.cacheAuthenticationInfoIfPossible(AuthenticatingRealm.java:507) AuthenticationInfo caching is disabled for info [admin]. Submitted token: [org.apache.shiro.authc.UsernamePasswordToken - admin, rememberMe=false].
[DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:104) Creating a new SqlSession
[DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:140) SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@33b81d6e] was not registered for synchronization because synchronization is not active
[DEBUG][2018-12-24 21:47:08] org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:110) Fetching JDBC Connection from DataSource
[DEBUG][2018-12-24 21:47:08] org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:86) JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@41131e6d] will not be managed by Spring
[DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Preparing: SELECT cu.user_id AS user_id4, login_name, login_password, salt, user_name, real_name, sex, age, pic_img, cu.status AS status4, email, telephone, cu.create_time AS create_time4, cu.update_time AS update_time4, cr.role_id AS role_id2, role_name, role_sign, is_system, cr.status AS status2, cr.create_time AS create_time2, cr.update_time AS update_time2, cr.remarks AS remarks2, cm.menu_id AS menu_id1, parent_id, menu_type, menu_code, menu_name, sort, href, icon, cm.status AS status1, permission, cm.create_time AS create_time1, cm.update_time AS update_time1, cm.remarks AS remarks1 FROM cms_menu cm, cms_role cr, cms_role_menu crm, cms_user cu, cms_user_role cur WHERE crm.role_id = cr.role_id AND crm.menu_id = cm.menu_id AND cur.user_id = cu.user_id AND cur.role_id = cr.role_id AND cu.login_name = ?;

[DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Parameters: admin(String)
[DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) <== Total: 73
[DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.closeSqlSession(SqlSessionUtils.java:168) Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@33b81d6e]
[DEBUG][2018-12-24 21:47:08] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:327) Returning JDBC Connection to DataSource
原密码:123456Dts7jk 加密之后的密码为:lZQ/OoEBjTylEoEfxoyWeQ==
[DEBUG][2018-12-24 21:47:08] org.apache.shiro.web.servlet.SimpleCookie.addCookieHeader(SimpleCookie.java:226) Added HttpServletResponse Cookie [rememberMe=deleteMe; Path=/shopCMS; Max-Age=0; Expires=Sun, 23-Dec-2018 13:47:08 GMT]
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain.invoke(ResponseBodyAdviceChain.java:61) Invoking ResponseBodyAdvice chain for body=login_fail
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain.invoke(ResponseBodyAdviceChain.java:83) After ResponseBodyAdvice chain body=login_fail
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:163) Written [login_fail] as "text/plain;charset=ISO-8859-1" using [org.springframework.http.converter.StringHttpMessageConverter@395cf6a4]
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1018) Null ModelAndView returned to DispatcherServlet with name 'SpringMVC': assuming HandlerAdapter completed request handling
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:996) Successfully completed request
[DEBUG][2018-12-24 21:47:08] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248) Returning cached instance of singleton bean 'sqlSessionFactory'
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:845) DispatcherServlet with name 'SpringMVC' processing GET request for [/shopCMS/login]
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:297) Looking up handler method for path /login
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:302) Returning handler method [public java.lang.String com.shop.shopmanager.controller.LoginController.login()]
[DEBUG][2018-12-24 21:47:08] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248) Returning cached instance of singleton bean 'loginController'
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:931) Last-Modified value for [/shopCMS/login] is: -1
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1225) Rendering view [org.springframework.web.servlet.view.JstlView: name 'login'; URL [/WEB-INF/views/login.jsp]] in DispatcherServlet with name 'SpringMVC'
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:166) Forwarding to resource [/WEB-INF/views/login.jsp] in InternalResourceView 'login'
[DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:996) Successfully completed request
[DEBUG][2018-12-24 21:47:08] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248) Returning cached instance of singleton bean 'sqlSessionFactory'


我的数据库中有admin和密码 123456,,但是就是无法跳转到登录后的页面希望大佬能帮我看看是什么原因》》》


后续添加,,,,麻烦大佬结合上述和下述看看是什么问题,,拜托拜托,

1:数据库用户表信息:
图片说明

2:我的项目结构:
图片说明

3:以下是登录控制器“LoginController”的代码:

package com.shop.shopmanager.controller;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shop.shopmanager.service.CmsUserService;

/**

  • @Author 康健
  • @Date 2017/8/14 14:54
    */
    @Controller
    @RequestMapping("login")
    public class LoginController {

    @Autowired
    private CmsUserService cmsUserService;
    /**

    • @Author JackWang [www.coder520.com]
    • @Date 2017/6/18 12:47
    • @Description 登录页面 */ @RequestMapping public String login() { return "login"; }

    /**

    • @Author JackWang [www.coder520.com]
    • @Date 2017/6/18 12:47
    • @Description 校验登录
      */
      @RequestMapping("/check")
      @ResponseBody
      public String checkLogin(HttpServletRequest request) throws UnsupportedEncodingException, NoSuchAlgorithmException {
      String username = request.getParameter("username");
      String pwd = request.getParameter("password");

      UsernamePasswordToken token = new UsernamePasswordToken(username, pwd);
      // token.setRememberMe(true);
      Subject subject = SecurityUtils.getSubject();
      try {
      subject.login(token);
      SecurityUtils.getSubject().getSession().setTimeout(1800000);
      } catch (Exception e) {
      return "login_fail";
      }
      return "login_succ";
      }

/*
@RequestMapping("/register")
@ResponseBody
public String register(@RequestBody User user) throws UnsupportedEncodingException, NoSuchAlgorithmException {

    userService.createUser(user);

    return "succ";
}*/

}

4:UsernamePasswordToken 我没有这个类,这好像是一个方法-------网上好像说这是个认证机制,,不知道跳转不了跟这个有没有关系

网上解释:是最常见的用户名/密码的认证机制;同时,由于它实现了RememberMeAuthenticationToken接口,我们可以通过令牌设置“记住我”的功能。 但是,“已记住”和“已认证”是有区别的: 已记住的用户仅仅是非匿名用户,你可以通过subject.getPrincipals()获取用户信息。但是它并非是认证通过的用户,当你访问需要认证用户的功能时,你仍然需要重新提交认证信息。 这一区别可以参考淘宝网站,网站会默认记住登录的用户,再次访问网站时,对于非敏感的页面功能,页面上会显示记住的用户信息,但是当你访问网站账户信息时仍然需要再次进行登录认证。

5: 我的自定义数据库配置“jdbc.properties”:
driverClassName=com.mysql.jdbc.Driver
validationQuery=SELECT 1
jdbc_url=jdbc:mysql://localhost:3306/shop?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
jdbc_username=root
jdbc_password=1234

6:"generatorConfig.xml" 这个就是上面的数据库驱动的配置
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >

<!--classPathEntry:数据库的JDBC驱动 -->
 <!--  location="D:\Develop\MvnRepo\mysql\mysql-connector-java\5.1.34\mysql-connector-java-5.1.34.jar"/> -->
<classPathEntry
        location="D:\Users\lydia\workspaceSSH\shopCMS\src\main\webapp\WEB-INF\lib\mysql-connector-java-5.1.34.jar"/>

<context id="MysqlTables" targetRuntime="MyBatis3">

    <!-- 注意这里面的顺序确定的,不能随变更改 -->
    <!-- 自定义的分页插件 <plugin type="com.deppon.foss.module.helloworld.shared.PaginationPlugin"/> -->

    <!-- 可选的(0 or 1) -->
    <!-- 注释生成器 -->
    <commentGenerator>
        <!-- 是否去除自动生成的注释 true:是 : false:否 -->
        <property name="suppressAllComments" value="true"/>
    </commentGenerator>

    <!-- 必须的(1 required) -->
    <!--数据库连接的信息:驱动类、连接地址、用户名、密码 
     connectionURL="jdbc:mysql://localhost:3306/work_attendance"
    -->
    <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                    connectionURL="jdbc:mysql://localhost:3306/shop"
                    userId="root" password="1234">
    </jdbcConnection>

    <!-- 可选的(0 or 1) -->
    <!-- 类型转换器或者加类型解析器 -->
    <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和
        NUMERIC 类型解析为java.math.BigDecimal -->
    <javaTypeResolver>
        <property name="forceBigDecimals" value="false"/>
    </javaTypeResolver>


    <!-- 必须的(1 required) -->
    <!-- java模型生成器 -->
    <!-- targetProject:自动生成代码的位置 -->
    <javaModelGenerator targetPackage="com.coder520.user.entity"
                        targetProject="D:\Develop\IDEAWorkPlace\work-attendance\src\main\java"
    >
        <!--TODO enableSubPackages:是否让schema作为包的后缀 -->
        <property name="enableSubPackages" value="true"/>
        <!-- 从数据库返回的值被清理前后的空格 -->
        <property name="trimStrings" value="true"/>
    </javaModelGenerator>

    <!-- 必须的(1 required) -->
    <!-- map xml 生成器 
    <sqlMapGenerator targetPackage="com.coder520.user.dao"
                     targetProject="D:\Develop\IDEAWorkPlace\work-attendance\src\main\java">
        <property name="enableSubPackages" value="true"/>
    </sqlMapGenerator>
    -->
    <sqlMapGenerator targetPackage="com.coder520.user.dao"
                     targetProject="D:\Users\lydia\workspaceSSH\shopCMS\src\main\java">
        <property name="enableSubPackages" value="true"/>
    </sqlMapGenerator>

    <!-- 可选的(0 or 1) -->
    <!-- mapper 或者就是dao接口生成器 -->
    <javaClientGenerator targetPackage="com.coder520.user.dao"
                         targetProject="D:\Users\lydia\workspaceSSH\shopCMS\src\main\java"
                         type="XMLMAPPER">
        <property name="enableSubPackages" value="true"/>
    </javaClientGenerator>

    <!-- 必须的(1...N) -->
    <!-- pojo 实体生成器 -->
    <!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 -->
    <!-- schema即为数据库名 可不写 -->
    <table tableName="role" domainObjectName="Role"
           enableInsert="true" enableCountByExample="false" enableUpdateByExample="false"
           enableDeleteByExample="false"
           enableSelectByExample="false" selectByExampleQueryId="false">
        <!-- 忽略字段 可选的(0 or 1) -->
        <!-- <ignoreColumn column="is_use" /> -->
        <!--//无论字段是什么类型,生成的类属性都是varchar。 可选的(0 or 1) 测试无效 -->
        <!-- <columnOverride column="city_code" jdbcType="VARCHAR" /> -->
    </table>
    <table tableName="permission" domainObjectName="Permission"
           enableInsert="true" enableCountByExample="false" enableUpdateByExample="false"
           enableDeleteByExample="false"
           enableSelectByExample="false" selectByExampleQueryId="false">
        <!-- 忽略字段 可选的(0 or 1) -->
        <!-- <ignoreColumn column="is_use" /> -->
        <!--//无论字段是什么类型,生成的类属性都是varchar。 可选的(0 or 1) 测试无效 -->
        <!-- <columnOverride column="city_code" jdbcType="VARCHAR" /> -->
    </table>


</context>

万分感谢大佬,,,,,帮我解决这问题我就认你当师傅,,,大佬 ,,拜托了,,,还需要什么麻烦留下言哈

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答