问题:
java.lang.NoSuchMethodException: com.lnzkx.action.PersonAction.getSinglePerson()
java.lang.NoSuchMethodException: 这个异常往往都是指,调用了不存在的方法
解决:
struts.xml配置method里方法名一定要和action的方法名一致
<action name="getSinglePerson" class="com.lnzkx.action.PersonAction" method="getSinglePerson">
<result>/getSinglePerson.jsp</result>
</action>
————————————
public String getSinglePerson() throws Exception{
PersonService personservice = new PersonServiceImpl();
Person person =personservice.getSinglePersonById(id);
HttpServletRequest request = ServletActionContext.getRequest();
request.setAttribute("person", person);
return SUCCESS;
}
总结:
还是.xml里配置一定要仔细了