无法传递参数apache shiro jsp sevlet

时间:2019-06-03 07:43:14

标签: java apache jsp shiro jdbcrealm

提交表单后,参数未传递到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>

1 个答案:

答案 0 :(得分:1)

请这样更改您的表单操作

myrun = 00; % 00 06 12 18
mydate = 20190603; % yearmonthday
myforecasthour = 039; % t + number of hours ahead
fullURL=['https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25_1hr.pl?file=gfs.t',num2str(myrun,'%02.f'),'z.pgrb2.0p25.f',num2str(myforecasthour,'%03.f'),'&lev_surface=on&var_CAPE=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=%2Fgfs.',num2str(mydate)'];

filename = 'cape_test';
urlwrite(fullURL,filename);