开发者社区> 问答> 正文

各项配置已经配置好了还是有问题:报错

首先是页面:这里没有用s标签,是因为我需要用第三方的前端框架,用了s标签那些就不可以用了

<form action="users/reg.action" method="post" name="regForm">
<div class="control-group">
<input type="text" name="mail" placeholder="您的邮箱" /> 
</div>
<div class="control-group">
<input type="password"  name="pswd1" placeholder="您的密码" />
</div>
<div class="control-group">
<input type="password"  name="pswd2" placeholder="请确认密码" />
</div>
<div class="control-group">
<input type="text" name="name" placeholder="您的姓名" /> 
</div>
<div class="control-group">
<input type="text"  name="phone" value="" placeholder="您的手机号码(非必填)" />
</div>
</div>
<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
<input type="submit" class="btn btn-primary" value="确定注册" />
然后 Struts.xml的配置:
<constant name="struts.i18n.encoding" value="UTF-8" />
	<constant name="struts.configuration.xml.reload" value="true"></constant>
	<constant name="struts.objectFactory" value="spring"/>
	<package name="UserPart" extends="struts-default" namespace="/users">

	<action name="login" class="loginAction" >
		<result name="success">/u/index.jsp</result>
		<result name="input">/index.jsp</result>
	</action>
	<action name="reg" class="regAction">
		<result name="input">/index.jsp</result>
		<result name="success">/u/reg.jsp</result>
	</action></package>
以及Action:这边可以确定是已经进入了execute方法。
public String execute() {
		if (!pswd1.equals(pswd2))
			return INPUT;
		if (name.length() > 15)
			return INPUT;
		if (mail.indexOf("@") < 1
				|| mail.lastIndexOf(".") < mail.lastIndexOf("@"))
			return INPUT;
		Users user = usersService.getByMail(mail);
		if (user == null)
			return INPUT;
		String password = MD5.md5s(pswd1);
		usersService.addUser(mail, password, name, phone);
		return SUCCESS;

	}
还有applicationContext.xml的配置:
<bean id="regAction" class="com.hzdaily.action.regAction" scope="prototype">
		<property name="usersService" ref="usersService"/>
	</bean>
这些应该基本是没问题的 但还是会出现没有定义result的问题。。

还有web.xml,应该也是没问题的,现在是控制台不打错误了,而网页页面会是这样,但是既然已经提示了准确的Action名称,而且在相应的execute自行打印其他字符的时候,也确认是执行了execute方法。

<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>hzdaily</display-name>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
  </filter-mapping>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <filter>
  	<filter-name>OpenSessionInViewFilter</filter-name>
  	<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
  </filter>
  <filter-mapping>
  	<filter-name>OpenSessionInViewFilter</filter-name>
  	<url-pattern>*.action</url-pattern>
  </filter-mapping>
</web-app>
纠结了好久了。。求大神们帮帮忙吧。

整体是 Struts2.1+hibernate4+Spring3

展开
收起
kun坤 2020-06-14 06:58:13 634 0
1 条回答
写回答
取消 提交回答
  • clean restart.
    ######restart是指server?######看了半天,表示没看出问题来。。。 ######一般是对应的jsp文件没找到,好好检查一下######jsp文件是存在的。。。这个问题上午莫名其妙好了以后。再添加的又出错了。。

    2020-06-14 06:58:19
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
内容安全检测与管控 立即下载
《用管控策略设定多账号组织全局访问边界》 立即下载
Tsar-灵活的系统和应用采集软件 立即下载