例子,表单和JDBCRealm的安全验证
1、要在wab.xml中进行修改,但基本和basic一样,只要修改就可以
FORM
/jsp/SecurityLogin.jsp
/jsp/SecurityError.jsp
上面有两个登录和出错的jsp界面,登录界面可以填入表单,这里要注意表单的acton="j_security_check"
用户名的输入
密码的输入
2、在tomcat下的/conf/server.xml,配置
driverName="com.mysql.jdbc.Driver"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
connectionURL="jdbc:mysql://localhost:3306/smarketonline?user=admin&password=password"
userTable="users"
userNameCol="username"
userCredCol="password"
userRoleTable="roles"
roleNameCol="role"/>
这里在数据库中建立了,两个表
users表
roles表
这里要注意users表的username 要和roles表的uesrname一样,否则会报错,’找不到列‘的错误
最后,在登录时输入数据库中存放的的数据就可以了