读书人

struts2使用convention解决方案

发布时间: 2014-02-22 10:53:57 作者: rapoo

struts2使用convention
我配置struts2环境是正确的,然后加入convention的jar包,不能获取数据。不知道什么原因。求指教!!!
struts2文件:
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.convention.package.locators" value="action" />
<constant name="struts.convention.result.path" value="/WEB-INF/template/"/>
</struts>

web文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
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">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<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>/*</url-pattern>
</filter-mapping>

</web-app>
java文件:
package com.convention.base.actions;

import com.opensymphony.xwork2.ActionSupport;

public class HelloWorld extends ActionSupport {
private String message;

public String getMessage() {
return message;
}

public String execute(){
message="Hello,World!";
return SUCCESS;
}
}
jsp文件:
<html>
<body>
The message is ${message}
</body>
</html>


[解决办法]
配置文件都没有配怎么访问??

读书人网 >Web开发

热点推荐