我正在修改我的应用程序,将所有.jsp页面重命名为.html。
修改后的shiro.ini如下所示:
[main]
shiro.loginUrl = /login.html
dataSource = org.apache.shiro.jndi.JndiObjectFactory
dataSource.resourceName = java:/comp/env/jdbc/myappDB
credentialsMatcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.dataSource = $dataSource
jdbcRealm.credentialsMatcher = $credentialsMatcher
[filters]
[urls]
/login.html = authc
/logout = logout
/secure/** = authc
/api/** = authcBasic, rest
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<welcome-file-list>
<welcome-file>appmain.html</welcome-file>
</welcome-file-list>
</web-app>
几点:
关于可能出错的任何指示?
答案 0 :(得分:0)
我原来的shiro.ini出现了问题。 [main]下面的第一行以shiro.loginURL
开头,实际应该是shiro.loginUrl
。我做了这个改变,我的应用程序现在运行正常。我也在编辑问题以显示正确的语法。我已经接受了我自己的答案来完成/关闭这个问题。