无法传递参数 apache shiro jsp servlet
Cannot pass parameters apache shiro jsp sevlet
表单提交后,参数没有传递给servlet。 Html 附上提交页面。在 shiro.ini 文件中有 JDBC 领域。
`<form name="loginForm" method="get" action="LoginCheckController">
<table width="20%" bgcolor="0099CC" align="center">
<input type="hidden" id="action" name="page" value="home"/>
<tr>
<td colspan=2><center>
<font size=4><b>HTML Login Page</b></font>
</center></td>
</tr>
<tr>
<td>Username:</td>
<td><input name="username" id="username" type="text" size=25 ></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" type="password" size=25 ></td>
</tr>
<tr>
<td><input type="Reset"></td>
<td><input type="submit" value="Login"></td>
</tr>
</table>
</form>`
这是shiro.ini配置文件。有一个 jdbc 领域。它用于获取日志记录详细信息。初始日志记录文件是 login.jsp。所有参数都给出了空结果。
[main]
##creating the realm
jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.permissionsLookupEnabled = true
jdbcRealm.authenticationQuery = SELECT password FROM users WHERE username = ?
jdbcRealm.userRolesQuery = SELECT rolename FROM userroles WHERE username = ?
jdbcRealm.permissionsQuery = SELECT permission FROM rolepermissions WHERE roleid=(SELECT roleid from roles where rolename= ? )
##connection pooling and database access through apache commons dbcp
ds = org.apache.commons.dbcp.BasicDataSource
ds.driverClassName = oracle.jdbc.driver.OracleDriver
ds.username=nextgen
ds.password =nextgen
ds.url = jdbc:oracle:thin:@192.168.1.50:1521:orcl
##adding the data source to the realm earlier configured
jdbcRealm.dataSource = $ds
##password encryption is done by sha256 encryption algorithm provided by shiro api
Md5Matcher = org.apache.shiro.authc.credential.Md5CredentialsMatcher
jdbcRealm.credentialsMatcher = $Md5Matcher
##configuring security manager to use the realm configured earlier
securityManager.realms=$jdbcRealm
##Caching mechanism is dome by a third party chaching api called ehcache
##adding the chaching support to the security manager
cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
securityManager.cacheManager = $cacheManager
[filters]
shiro.loginUrl =/login
##url section is used to set permissions to specific urls
[urls]
/language/** = anon
/res/**= anon
/theme/html/** = anon
/theme/mobile/** = anon
/view/mobile/login.html= anon
/view/html/login/brokerDetailEnglish.html=anon
/view/html/login/brokerDetailSinhala.html=anon
/view/html/scripts/**=anon
/view/mobile/scripts/**=anon
/login.jsp = authc
/view/html/home.jsp = authc, roles[user]
/view/xml/home.jsp = authc, perms[users:xml:home]
/** = authc
<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>testP</display-name>
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
<init-param>
<param-name>configPath</param-name>
<param-value>/WEB-INF/shiro.ini</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login</welcome-file>
</welcome-file-list>
<servlet-mapping>
<servlet-name>LoginCheckController</servlet-name>
<url-pattern>/LoginCheckController</url-pattern>
<url-pattern>/login</url-pattern>
</servlet-mapping>
</web-app>
请像这样更改您的表单操作
<form name="loginForm" method="post" action="login">
表单提交后,参数没有传递给servlet。 Html 附上提交页面。在 shiro.ini 文件中有 JDBC 领域。
`<form name="loginForm" method="get" action="LoginCheckController">
<table width="20%" bgcolor="0099CC" align="center">
<input type="hidden" id="action" name="page" value="home"/>
<tr>
<td colspan=2><center>
<font size=4><b>HTML Login Page</b></font>
</center></td>
</tr>
<tr>
<td>Username:</td>
<td><input name="username" id="username" type="text" size=25 ></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" type="password" size=25 ></td>
</tr>
<tr>
<td><input type="Reset"></td>
<td><input type="submit" value="Login"></td>
</tr>
</table>
</form>`
这是shiro.ini配置文件。有一个 jdbc 领域。它用于获取日志记录详细信息。初始日志记录文件是 login.jsp。所有参数都给出了空结果。
[main]
##creating the realm
jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.permissionsLookupEnabled = true
jdbcRealm.authenticationQuery = SELECT password FROM users WHERE username = ?
jdbcRealm.userRolesQuery = SELECT rolename FROM userroles WHERE username = ?
jdbcRealm.permissionsQuery = SELECT permission FROM rolepermissions WHERE roleid=(SELECT roleid from roles where rolename= ? )
##connection pooling and database access through apache commons dbcp
ds = org.apache.commons.dbcp.BasicDataSource
ds.driverClassName = oracle.jdbc.driver.OracleDriver
ds.username=nextgen
ds.password =nextgen
ds.url = jdbc:oracle:thin:@192.168.1.50:1521:orcl
##adding the data source to the realm earlier configured
jdbcRealm.dataSource = $ds
##password encryption is done by sha256 encryption algorithm provided by shiro api
Md5Matcher = org.apache.shiro.authc.credential.Md5CredentialsMatcher
jdbcRealm.credentialsMatcher = $Md5Matcher
##configuring security manager to use the realm configured earlier
securityManager.realms=$jdbcRealm
##Caching mechanism is dome by a third party chaching api called ehcache
##adding the chaching support to the security manager
cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
securityManager.cacheManager = $cacheManager
[filters]
shiro.loginUrl =/login
##url section is used to set permissions to specific urls
[urls]
/language/** = anon
/res/**= anon
/theme/html/** = anon
/theme/mobile/** = anon
/view/mobile/login.html= anon
/view/html/login/brokerDetailEnglish.html=anon
/view/html/login/brokerDetailSinhala.html=anon
/view/html/scripts/**=anon
/view/mobile/scripts/**=anon
/login.jsp = authc
/view/html/home.jsp = authc, roles[user]
/view/xml/home.jsp = authc, perms[users:xml:home]
/** = authc
<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>testP</display-name>
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
<init-param>
<param-name>configPath</param-name>
<param-value>/WEB-INF/shiro.ini</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login</welcome-file>
</welcome-file-list>
<servlet-mapping>
<servlet-name>LoginCheckController</servlet-name>
<url-pattern>/LoginCheckController</url-pattern>
<url-pattern>/login</url-pattern>
</servlet-mapping>
</web-app>
请像这样更改您的表单操作
<form name="loginForm" method="post" action="login">