当前位置: 代码迷 >> Web开发 >> struts2使用convention解决思路
  详细解决方案

struts2使用convention解决思路

热度:115   发布时间:2013-10-10 14:14:51.0
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>


------解决方案--------------------
配置文件都没有配怎么访问??
  相关解决方案