项目是使用JSP/SERVLET + TOMCAT开发,
在使用form认证时做了如下修改:
1.在TOMCAT的server.xml中<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="org.postgresql.Driver"
connectionURL="jdbc:postgresql://192.168.1.13:5732/BLGDB"
connectionName="postgres" connectionPassword="postgres"
userTable="blg_user" userNameCol="userid" userCredCol="password"
/>
2.在项目web.xml中添加如下
<security-constraint>
<web-resource-collection>
<web-resource-name>Protect Pages</web-resource-name>
<url-pattern>/jsp/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>test</role-name>
</auth-constraint>
</security-constraint> <login-config>
<auth-method>FORM</auth-method>
<realm-name>Web Demo</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>3.在login.jsp中有如下:
<form method="POST" action="j_security_check">
<input type="text" name="j_username">
<input type="password" name="j_password">
<input type="submit" value="Log in">
</form>
*附:
<role-name>test</role-name>中的用户是在TOMCAT的tomcat-users.xml中如下添加
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="test" password="tomcat" roles="tomcat,role1"/>
<user username="admin" password="linaren" roles="admin,manager"/>
</tomcat-users>========================================================================
如上完成后,在IE中直接输入JSP下的某个页面的URL时,会转到login.jsp,但输入用户名与密码后一登陆就直接出现错误,用error.jsp输出时发现exception是空的!问:这是什么原因?怎么解决?谢谢
在使用form认证时做了如下修改:
1.在TOMCAT的server.xml中<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="org.postgresql.Driver"
connectionURL="jdbc:postgresql://192.168.1.13:5732/BLGDB"
connectionName="postgres" connectionPassword="postgres"
userTable="blg_user" userNameCol="userid" userCredCol="password"
/>
2.在项目web.xml中添加如下
<security-constraint>
<web-resource-collection>
<web-resource-name>Protect Pages</web-resource-name>
<url-pattern>/jsp/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>test</role-name>
</auth-constraint>
</security-constraint> <login-config>
<auth-method>FORM</auth-method>
<realm-name>Web Demo</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>3.在login.jsp中有如下:
<form method="POST" action="j_security_check">
<input type="text" name="j_username">
<input type="password" name="j_password">
<input type="submit" value="Log in">
</form>
*附:
<role-name>test</role-name>中的用户是在TOMCAT的tomcat-users.xml中如下添加
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="test" password="tomcat" roles="tomcat,role1"/>
<user username="admin" password="linaren" roles="admin,manager"/>
</tomcat-users>========================================================================
如上完成后,在IE中直接输入JSP下的某个页面的URL时,会转到login.jsp,但输入用户名与密码后一登陆就直接出现错误,用error.jsp输出时发现exception是空的!问:这是什么原因?怎么解决?谢谢
解决方案 »
- 两控件相互拖拽数据
- 各位大侠!java中怎样才能使只有登陆了才能对主页面进行操作,否则返回登录页面重新登录
- Hibernate 级联问题
- 请看看这段代码有什么问题
- 头痛一天了 jsp如何调用class文件
- 请问重定向与跳转的区别?谢谢!!!
- [SOS]:有没有办法做到 在重置了JavaBean后而不重启服务器
- DetachedCriteria查询,怎么通过给定的单词去查询不包含这些单词的信息?
- 今天非常不爽,散分
- 我写的servlet一段代码,为什么在运行时,总要提示下载,我用的是tomcat3.2。
- 招聘:广东佛山市高明区金得利科技有限公司招聘JSP程序员,待遇从优。
- jsp 中实现实时筛选?
你调试下Exception对象的信息吧。